Skip to content

Commit

Permalink
Fixing loading of default options in CakePlugin::loadAll(), fixes #1737
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jul 15, 2011
1 parent a025cb2 commit 8a6d97d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/Cake/Core/CakePlugin.php
Expand Up @@ -97,8 +97,11 @@ public static function load($plugin, $config = array()) {
public function loadAll($options = array()) {
$plugins = App::objects('plugins');
foreach ($plugins as $p) {
$opts = isset($options[$p]) ? $options[$p] : $options;
self::load($p, $opts);
$opts = isset($options[$p]) ? $options[$p] : null;
if ($opts === null && isset($options[0])) {
$opts = $options[0];
}
self::load($p, (array) $opts);
}
}

Expand Down
5 changes: 3 additions & 2 deletions lib/Cake/Test/Case/Core/CakePluginTest.php
Expand Up @@ -216,7 +216,8 @@ public function testLoadAll() {
* @return void
*/
public function testLoadAllWithDefaults() {
CakePlugin::loadAll(array('bootstrap' => true));
$defaults = array('bootstrap' => true);
CakePlugin::loadAll(array($defaults));
$expected = array('PluginJs', 'TestPlugin', 'TestPluginTwo');
$this->assertEquals($expected, CakePlugin::loaded());
$this->assertEquals('loaded js plugin bootstrap', Configure::read('CakePluginTest.js_plugin.bootstrap'));
Expand All @@ -231,7 +232,7 @@ public function testLoadAllWithDefaults() {
* @return void
*/
public function testLoadAllWithDefaultsAndOverride() {
CakePlugin::loadAll(array('bootstrap' => true, 'TestPlugin' => array('routes' => true)));
CakePlugin::loadAll(array(array('bootstrap' => true), 'TestPlugin' => array('routes' => true)));
CakePlugin::routes();

$expected = array('PluginJs', 'TestPlugin', 'TestPluginTwo');
Expand Down

0 comments on commit 8a6d97d

Please sign in to comment.