Skip to content

Commit

Permalink
Fixing issues where paths added to build() would be appended into the…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
markstory committed Mar 26, 2010
1 parent 2e11f63 commit d20aa23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cake/libs/configure.php
Expand Up @@ -683,11 +683,13 @@ function build($paths = array(), $reset = false) {
$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 {
Expand Down
5 changes: 4 additions & 1 deletion cake/tests/cases/libs/configure.test.php
Expand Up @@ -323,8 +323,8 @@ function testBuild() {
$new = App::path('models');

$expected = array(
APP . 'models' . DS,
'/path/to/models/',
APP . 'models' . DS,
APP,
ROOT . DS . LIBS . 'model' . DS
);
Expand Down Expand Up @@ -599,9 +599,12 @@ function testImportingHelpersFromAlternatePaths() {
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();
}

/**
Expand Down

0 comments on commit d20aa23

Please sign in to comment.