mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Make CakePlugin::loadAll behave correctly regarding merging of settings.
This commit is contained in:
parent
debdc6bccc
commit
9058f0f6f1
2 changed files with 23 additions and 5 deletions
|
@ -121,9 +121,9 @@ class CakePlugin {
|
||||||
public static function loadAll($options = array()) {
|
public static function loadAll($options = array()) {
|
||||||
$plugins = App::objects('plugins');
|
$plugins = App::objects('plugins');
|
||||||
foreach ($plugins as $p) {
|
foreach ($plugins as $p) {
|
||||||
$opts = isset($options[$p]) ? $options[$p] : null;
|
$opts = isset($options[$p]) ? $options[$p] : array();
|
||||||
if ($opts === null && isset($options[0])) {
|
if (isset($options[0])) {
|
||||||
$opts = $options[0];
|
$opts += $options[0];
|
||||||
}
|
}
|
||||||
self::load($p, (array)$opts);
|
self::load($p, (array)$opts);
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,8 +253,8 @@ class CakePluginTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that CakePlugin::loadAll() will load all plugins in the configured folder wit defaults
|
* Tests that CakePlugin::loadAll() will load all plugins in the configured folder with defaults
|
||||||
* and overrides for a plugin
|
* and merges in global defaults.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
@ -262,6 +262,24 @@ class CakePluginTest extends CakeTestCase {
|
||||||
CakePlugin::loadAll(array(array('bootstrap' => true), 'TestPlugin' => array('routes' => true)));
|
CakePlugin::loadAll(array(array('bootstrap' => true), 'TestPlugin' => array('routes' => true)));
|
||||||
CakePlugin::routes();
|
CakePlugin::routes();
|
||||||
|
|
||||||
|
$expected = array('PluginJs', 'TestPlugin', 'TestPluginTwo');
|
||||||
|
$this->assertEquals($expected, CakePlugin::loaded());
|
||||||
|
$this->assertEquals('loaded js plugin bootstrap', Configure::read('CakePluginTest.js_plugin.bootstrap'));
|
||||||
|
$this->assertEquals('loaded plugin routes', Configure::read('CakePluginTest.test_plugin.routes'));
|
||||||
|
$this->assertEquals('loaded plugin bootstrap', Configure::read('CakePluginTest.test_plugin.bootstrap'));
|
||||||
|
$this->assertEquals('loaded plugin two bootstrap', Configure::read('CakePluginTest.test_plugin_two.bootstrap'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that CakePlugin::loadAll() will load all plugins in the configured folder with defaults
|
||||||
|
* and overrides for a plugin
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testLoadAllWithDefaultsAndOverrideComplex() {
|
||||||
|
CakePlugin::loadAll(array(array('bootstrap' => true), 'TestPlugin' => array('routes' => true, 'bootstrap' => false)));
|
||||||
|
CakePlugin::routes();
|
||||||
|
|
||||||
$expected = array('PluginJs', 'TestPlugin', 'TestPluginTwo');
|
$expected = array('PluginJs', 'TestPlugin', 'TestPluginTwo');
|
||||||
$this->assertEquals($expected, CakePlugin::loaded());
|
$this->assertEquals($expected, CakePlugin::loaded());
|
||||||
$this->assertEquals('loaded js plugin bootstrap', Configure::read('CakePluginTest.js_plugin.bootstrap'));
|
$this->assertEquals('loaded js plugin bootstrap', Configure::read('CakePluginTest.js_plugin.bootstrap'));
|
||||||
|
|
Loading…
Add table
Reference in a new issue