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
This commit is contained in:
gwoo 2008-01-01 22:52:25 +00:00
parent 852fa4e921
commit 0156b9e689

View file

@ -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();