From e4545dbe5ec6a8a6ea9b320c85f67ab97b66b2de Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 28 Aug 2010 00:19:09 -0400 Subject: [PATCH] Fixing failing tests in Dispatcher.test. --- cake/dispatcher.php | 6 +--- cake/libs/view/helper_collection.php | 2 +- cake/tests/cases/dispatcher.test.php | 47 +--------------------------- 3 files changed, 3 insertions(+), 52 deletions(-) diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 1ca1f9f9b..e35534d8f 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -317,11 +317,7 @@ class Dispatcher { } $controller = null; $view = new View($controller); - $return = $view->renderCache($filename, microtime(true)); - if (!$return) { - ClassRegistry::removeObject('view'); - } - return $return; + return $view->renderCache($filename, microtime(true)); } } return false; diff --git a/cake/libs/view/helper_collection.php b/cake/libs/view/helper_collection.php index fd87c7d4e..74683db93 100644 --- a/cake/libs/view/helper_collection.php +++ b/cake/libs/view/helper_collection.php @@ -62,7 +62,7 @@ class HelperCollection extends ObjectCollection { } $this->_loaded[$name] = new $helperClass($this->_View, $settings); - $vars = array('base', 'webroot', 'here', 'params', 'action', 'data', 'theme', 'plugin'); + $vars = array('request', 'base', 'webroot', 'here', 'params', 'action', 'data', 'theme', 'plugin'); foreach ($vars as $var) { $this->_loaded[$name]->{$var} = $this->_View->{$var}; } diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index bbda338e3..5348e01a1 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -852,7 +852,6 @@ class DispatcherTest extends CakeTestCase { Router::reload(); Configure::write('App.baseUrl', '/index.php'); $Dispatcher = new TestDispatcher(); - Configure::write('App.baseUrl','/index.php'); $url = array('controller' => 'pages', 'action' => 'display'); $controller = $Dispatcher->dispatch($url, array( @@ -866,7 +865,7 @@ class DispatcherTest extends CakeTestCase { $expected = array('0' => 'home', 'param' => 'value', 'param2' => 'value2'); $this->assertIdentical($expected, $controller->passedArgs); - $this->assertEqual($Dispatcher->base . '/pages/display/home/param:value/param2:value2', $Dispatcher->here); + $this->assertEqual($Dispatcher->request->base . '/pages/display/home/param:value/param2:value2', $Dispatcher->request->here); } /** @@ -1583,50 +1582,6 @@ class DispatcherTest extends CakeTestCase { unlink($filename); } -/** - * test that cached() registers a view and un-registers it. Tests - * that helpers using don't fail - * - * @return void - */ - function testCachedRegisteringViewObject() { - Configure::write('Cache.disable', false); - Configure::write('Cache.check', true); - Configure::write('debug', 2); - - $_POST = array(); - $_SERVER['PHP_SELF'] = '/'; - - Router::reload(); - App::build(array( - 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) - )); - - $dispatcher = new TestDispatcher(); - $dispatcher->response = $this->getMock('CakeResponse', array('_sendHeader')); - $dispatcher->base = false; - - $url = 'test_cached_pages/cache_form'; - ob_start(); - $dispatcher->dispatch($url); - $out = ob_get_clean(); - - ClassRegistry::flush(); - - ob_start(); - $dispatcher->cached($url); - $cached = ob_get_clean(); - - $result = str_replace(array("\t", "\r\n", "\n"), "", $out); - $cached = preg_replace('//', '', $cached); - $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); - - $this->assertEqual($result, $expected); - $filename = $this->__cachePath($dispatcher->here); - @unlink($filename); - ClassRegistry::flush(); - } - /** * testHttpMethodOverrides method *