From 0156b9e689cd2f719de5d362917057b379f022ed Mon Sep 17 00:00:00 2001 From: gwoo Date: Tue, 1 Jan 2008 22:52:25 +0000 Subject: [PATCH] adding test for root path caching, closes #1349 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6298 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/tests/cases/dispatcher.test.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index 07c7df1b7..0e7c06587 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -784,15 +784,40 @@ class DispatcherTest extends UnitTestCase { Configure::write('debug', 2); $_POST = array(); - $_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php'; + $_SERVER['PHP_SELF'] = '/'; Router::reload(); + Router::connect('/', array('controller' => 'test_cached_pages', 'action' => 'index')); Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)); $dispatcher =& new Dispatcher(); $dispatcher->base = false; + $url = '/'; + + restore_error_handler(); + ob_start(); + $dispatcher->dispatch($url); + $out = ob_get_clean(); + + ob_start(); + $dispatcher->cached($url); + $cached = ob_get_clean(); + + set_error_handler('simpleTestErrorHandler'); + + $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 = CACHE . 'views' . DS . Inflector::slug($dispatcher->here) . '.php'; + unlink($filename); + + + $dispatcher->base = false; + $url = 'test_cached_pages/index'; restore_error_handler();