From d20aa237116912d3e156079ea7ebff600443aa82 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Thu, 25 Mar 2010 23:44:40 -0400 Subject: [PATCH] Fixing issues where paths added to build() would be appended into the search paths after the default paths. Fixed issue where paths added with build() would be lost when calling build() again to change a different path type. Tests updated. Fixes #410 --- cake/libs/configure.php | 6 ++++-- cake/tests/cases/libs/configure.test.php | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cake/libs/configure.php b/cake/libs/configure.php index 40f9b0041..692002aa7 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -683,11 +683,13 @@ class App extends Object { $merge = array_merge($merge, (array)$core[$type]); } - $_this->{$type} = $default; + if (empty($_this->{$type}) || empty($paths)) { + $_this->{$type} = $default; + } if (!empty($paths[$type])) { $path = array_flip(array_flip(array_merge( - $_this->{$type}, (array)$paths[$type], $merge + (array)$paths[$type], $_this->{$type}, $merge ))); $_this->{$type} = array_values($path); } else { diff --git a/cake/tests/cases/libs/configure.test.php b/cake/tests/cases/libs/configure.test.php index dc153c3f3..46c8ea069 100644 --- a/cake/tests/cases/libs/configure.test.php +++ b/cake/tests/cases/libs/configure.test.php @@ -323,8 +323,8 @@ class AppImportTest extends CakeTestCase { $new = App::path('models'); $expected = array( - APP . 'models' . DS, '/path/to/models/', + APP . 'models' . DS, APP, ROOT . DS . LIBS . 'model' . DS ); @@ -599,9 +599,12 @@ class AppImportTest extends CakeTestCase { App::build(array( 'helpers' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'helpers' . DS) )); + App::build(array('vendors' => array(TEST_CAKE_CORE_INCLUDE_PATH))); $this->assertFalse(class_exists('BananaHelper'), 'BananaHelper exists, cannot test importing it.'); App::import('Helper', 'Banana'); $this->assertTrue(class_exists('BananaHelper'), 'BananaHelper was not loaded.'); + + App::build(); } /**