Skip to content

Commit

Permalink
Unloading all plugins with App::build() and $reset parameter is true
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed May 6, 2011
1 parent 27a134d commit f18b9aa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
3 changes: 3 additions & 0 deletions lib/Cake/Core/App.php
Expand Up @@ -226,6 +226,8 @@ public static function path($type, $plugin = null) {
*
* `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
Expand Down Expand Up @@ -303,6 +305,7 @@ public static function build($paths = array(), $reset = false) {
}
self::$__packages[$type] = (array)$new;
}
CakePlugin::unload();
return $paths;
}

Expand Down
1 change: 0 additions & 1 deletion lib/Cake/tests/Case/Core/CakePluginTest.php
Expand Up @@ -27,7 +27,6 @@ public function setUp() {
*/
public function tearDown() {
App::build();
CakePlugin::unload();
Configure::delete('CakePluginTest');
}

Expand Down
35 changes: 18 additions & 17 deletions lib/Cake/tests/Case/View/ViewTest.php
Expand Up @@ -200,7 +200,7 @@ function setUp() {
LIBS . 'tests' . DS . 'test_app' . DS . 'View'. DS
)
), true);

CakePlugin::loadAll();
Configure::write('debug', 2);
}

Expand All @@ -224,18 +224,18 @@ function tearDown() {
* @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);
}
Expand All @@ -246,7 +246,7 @@ function testPluginGetTemplate() {
* @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';
Expand All @@ -256,13 +256,13 @@ function testPluginPathGeneration() {
$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
);
Expand All @@ -286,11 +286,12 @@ function testCamelCasePluginGetTemplate() {
'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);
}
Expand Down Expand Up @@ -331,8 +332,8 @@ function testGetTemplate() {
$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);
Expand Down Expand Up @@ -427,10 +428,10 @@ function testElement() {
$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');

Expand Down

0 comments on commit f18b9aa

Please sign in to comment.