mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Unloading all plugins with App::build() and $reset parameter is true
This commit is contained in:
parent
27a134de4f
commit
f18b9aae7b
3 changed files with 21 additions and 18 deletions
|
@ -226,6 +226,8 @@ class App {
|
|||
*
|
||||
* `App::build(array('View/Helper' => array('/path/to/models/', '/another/path/))); will setup multiple search paths for helpers`
|
||||
*
|
||||
* If reset is set to true, all loaded plugins will be forgotten and they will be needed to be loaded again.
|
||||
*
|
||||
* @param array $paths associative array with package names as keys and a list of directories for new search paths
|
||||
* @param boolean $reset true will set paths, false merges paths [default] false
|
||||
* @return void
|
||||
|
@ -303,6 +305,7 @@ class App {
|
|||
}
|
||||
self::$__packages[$type] = (array)$new;
|
||||
}
|
||||
CakePlugin::unload();
|
||||
return $paths;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ class CakePluginTest extends CakeTestCase {
|
|||
*/
|
||||
public function tearDown() {
|
||||
App::build();
|
||||
CakePlugin::unload();
|
||||
Configure::delete('CakePluginTest');
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ class ViewTest extends CakeTestCase {
|
|||
LIBS . 'tests' . DS . 'test_app' . DS . 'View'. DS
|
||||
)
|
||||
), true);
|
||||
|
||||
CakePlugin::loadAll();
|
||||
Configure::write('debug', 2);
|
||||
}
|
||||
|
||||
|
@ -224,18 +224,18 @@ class ViewTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testPluginGetTemplate() {
|
||||
$this->Controller->plugin = 'test_plugin';
|
||||
$this->Controller->plugin = 'TestPlugin';
|
||||
$this->Controller->name = 'TestPlugin';
|
||||
$this->Controller->viewPath = 'tests';
|
||||
$this->Controller->action = 'index';
|
||||
|
||||
$View = new TestView($this->Controller);
|
||||
|
||||
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'View' . DS .'tests' . DS .'index.ctp';
|
||||
$expected = CakePlugin::path('TestPlugin') . 'View' . DS .'tests' . DS .'index.ctp';
|
||||
$result = $View->getViewFileName('index');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'View' . DS . 'layouts' . DS .'default.ctp';
|
||||
$expected = CakePlugin::path('TestPlugin') . 'View' . DS . 'layouts' . DS .'default.ctp';
|
||||
$result = $View->getLayoutFileName();
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ class ViewTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testPluginPathGeneration() {
|
||||
$this->Controller->plugin = 'test_plugin';
|
||||
$this->Controller->plugin = 'TestPlugin';
|
||||
$this->Controller->name = 'TestPlugin';
|
||||
$this->Controller->viewPath = 'tests';
|
||||
$this->Controller->action = 'index';
|
||||
|
@ -256,13 +256,13 @@ class ViewTest extends CakeTestCase {
|
|||
$expected = array_merge(App::path('View'), App::core('View'));
|
||||
$this->assertEqual($paths, $expected);
|
||||
|
||||
$paths = $View->paths('test_plugin');
|
||||
|
||||
$paths = $View->paths('TestPlugin');
|
||||
$pluginPath = CakePlugin::path('TestPlugin');
|
||||
$expected = array(
|
||||
LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS . 'plugins' . DS . 'test_plugin' . DS,
|
||||
LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'View' . DS,
|
||||
LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'views' . DS,
|
||||
LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'Lib' . DS . 'View' . DS,
|
||||
LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS . 'plugins' . DS . 'TestPlugin' . DS,
|
||||
$pluginPath . 'View' . DS,
|
||||
$pluginPath . 'views' . DS,
|
||||
$pluginPath . 'Lib' . DS . 'View' . DS,
|
||||
LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS,
|
||||
LIBS . 'View' . DS
|
||||
);
|
||||
|
@ -286,11 +286,12 @@ class ViewTest extends CakeTestCase {
|
|||
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'View'. DS)
|
||||
));
|
||||
|
||||
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'View' . DS .'tests' . DS .'index.ctp';
|
||||
$pluginPath = CakePlugin::path('TestPlugin');
|
||||
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'TestPlugin' . DS . 'View' . DS .'tests' . DS .'index.ctp';
|
||||
$result = $View->getViewFileName('index');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'View' . DS . 'layouts' . DS .'default.ctp';
|
||||
$expected = $pluginPath. 'View' . DS . 'layouts' . DS .'default.ctp';
|
||||
$result = $View->getLayoutFileName();
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
@ -331,8 +332,8 @@ class ViewTest extends CakeTestCase {
|
|||
$result = $View->getLayoutFileName();
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$View->layoutPath = 'email' . DS . 'html';
|
||||
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS . 'layouts' . DS . 'email' . DS . 'html' . DS . 'default.ctp';
|
||||
$View->layoutPath = 'emails' . DS . 'html';
|
||||
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS . 'layouts' . DS . 'emails' . DS . 'html' . DS . 'default.ctp';
|
||||
$result = $View->getLayoutFileName();
|
||||
|
||||
$this->assertEqual($result, $expected);
|
||||
|
@ -427,10 +428,10 @@ class ViewTest extends CakeTestCase {
|
|||
$result = $this->View->element('test_element');
|
||||
$this->assertEqual($result, 'this is the test element');
|
||||
|
||||
$result = $this->View->element('plugin_element', array(), array('plugin' => 'test_plugin'));
|
||||
$result = $this->View->element('plugin_element', array(), array('plugin' => 'TestPlugin'));
|
||||
$this->assertEqual($result, 'this is the plugin element using params[plugin]');
|
||||
|
||||
$this->View->plugin = 'test_plugin';
|
||||
$this->View->plugin = 'TestPlugin';
|
||||
$result = $this->View->element('test_plugin_element');
|
||||
$this->assertEqual($result, 'this is the test set using View::$plugin plugin element');
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue