本文整理匯總了PHP中Dispatcher::cached方法的典型用法代碼示例。如果您正苦於以下問題:PHP Dispatcher::cached方法的具體用法?PHP Dispatcher::cached怎麽用?PHP Dispatcher::cached使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Dispatcher
的用法示例。
在下文中一共展示了Dispatcher::cached方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testCachedRegisteringViewObject
/**
* test that cached() registers a view and un-registers it. Tests
* that helpers using ClassRegistry::getObject('view'); 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 Dispatcher();
$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();
}
示例2: testFullPageCachingDispatch
/**
* testFullPageCachingDispatch method
*
* @return void
* @access public
*/
function testFullPageCachingDispatch()
{
Configure::write('Cache.disable', false);
Configure::write('Cache.check', true);
Configure::write('debug', 2);
$_POST = array();
$_SERVER['PHP_SELF'] = '/';
Router::reload();
Router::connect('/', array('controller' => 'test_cached_pages', 'action' => 'index'));
App::build(array('views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS)), true);
$dispatcher = new Dispatcher();
$dispatcher->base = false;
$url = '/';
ob_start();
$dispatcher->dispatch($url);
$out = ob_get_clean();
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);
$dispatcher->base = false;
$url = 'test_cached_pages/index';
ob_start();
$dispatcher->dispatch($url);
$out = ob_get_clean();
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);
$url = 'TestCachedPages/index';
ob_start();
$dispatcher->dispatch($url);
$out = ob_get_clean();
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);
$url = 'TestCachedPages/test_nocache_tags';
ob_start();
$dispatcher->dispatch($url);
$out = ob_get_clean();
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);
$url = 'test_cached_pages/view/param/param';
ob_start();
$dispatcher->dispatch($url);
$out = ob_get_clean();
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);
$url = 'test_cached_pages/view/foo:bar/value:goo';
ob_start();
$dispatcher->dispatch($url);
$out = ob_get_clean();
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);
$this->assertTrue(file_exists($filename));
unlink($filename);
}