From c20a8c80f39d26c57fa2b44aeb014dbb9e9c23a4 Mon Sep 17 00:00:00 2001 From: phpnut Date: Fri, 23 Mar 2007 10:34:21 +0000 Subject: [PATCH] Corrected view tests. Added fix for Ticket #2245 Refactored loading of components and helpers to allow for use of dot notation with plugins. git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4659 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/dispatcher.php | 4 ++++ cake/libs/controller/component.php | 8 ++++---- cake/libs/view/view.php | 10 +++++----- cake/tests/cases/libs/view/view.test.php | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 862564fdc..7e60ea0c5 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -353,6 +353,8 @@ class Dispatcher extends Object { $controller->output =& $output; foreach($controller->components as $c) { + $path = preg_split('/\/|\./', $c); + $c = $path[count($path) - 1]; if (isset($controller->{$c}) && is_object($controller->{$c}) && is_callable(array($controller->{$c}, 'shutdown'))) { if (!array_key_exists('enabled', get_object_vars($controller->{$c})) || $controller->{$c}->enabled == true) { $controller->{$c}->shutdown($controller); @@ -385,6 +387,8 @@ class Dispatcher extends Object { $controller->beforeFilter(); foreach($controller->components as $c) { + $path = preg_split('/\/|\./', $c); + $c = $path[count($path) - 1]; if (isset($controller->{$c}) && is_object($controller->{$c}) && is_callable(array($controller->{$c}, 'startup'))) { if (!array_key_exists('enabled', get_object_vars($controller->{$c})) || $controller->{$c}->enabled == true) { $controller->{$c}->startup($controller); diff --git a/cake/libs/controller/component.php b/cake/libs/controller/component.php index 3be6eda95..5b7b08787 100644 --- a/cake/libs/controller/component.php +++ b/cake/libs/controller/component.php @@ -85,13 +85,13 @@ class Component extends Object { $components[] = 'Session'; foreach($components as $component) { - $pos = strpos($component, '/'); - if ($pos === false) { + $parts = preg_split('/\/|\./', $component); + + if(count($parts) === 1) { $plugin = $this->controller->plugin; } else { - $parts = explode('/', $component); $plugin = Inflector::underscore($parts['0']); - $component = $parts['1']; + $component = $parts[count($parts) - 1]; } $componentCn = $component . 'Component'; diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index 4e9719af1..ab0b85c4a 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -373,7 +373,7 @@ class View extends Object { * @return string Rendered output */ function renderElement($name, $params = array(), $loadHelpers = false) { - + if(isset($params['plugin'])) { $this->plugin = $params['plugin']; $this->pluginPath = 'plugins' . DS . $this->plugin . DS; @@ -824,13 +824,13 @@ class View extends Object { $helpers[] = 'Session'; foreach($helpers as $helper) { - $pos = strpos($helper, '/'); - if ($pos === false) { + $parts = preg_split('/\/|\./', $helper); + + if(count($parts) === 1) { $plugin = $this->plugin; } else { - $parts = explode('/', $helper); $plugin = Inflector::underscore($parts['0']); - $helper = $parts['1']; + $helper = $parts[count($parts) - 1]; } $helperCn = $helper . 'Helper'; diff --git a/cake/tests/cases/libs/view/view.test.php b/cake/tests/cases/libs/view/view.test.php index d547e44e0..f3999c72b 100644 --- a/cake/tests/cases/libs/view/view.test.php +++ b/cake/tests/cases/libs/view/view.test.php @@ -54,7 +54,7 @@ class ViewTest extends UnitTestCase { } function testViewVars() { - $this->assertTrue($this->view->viewVars, array('testData' => 'Some test data', 'test2' => 'more data', 'test3' => 'even more data')); + $this->assertEqual($this->view->viewVars, array('testData' => 'Some test data', 'test2' => 'more data', 'test3' => 'even more data')); } function testUUIDGeneration() {