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
This commit is contained in:
Mark Story 2010-03-25 23:44:40 -04:00
parent 2e11f63bd4
commit d20aa23711
2 changed files with 8 additions and 3 deletions

View file

@ -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 {

View file

@ -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();
}
/**