當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Dispatcher::cached方法代碼示例

本文整理匯總了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();
 }
開發者ID:robksawyer,項目名稱:cakephp2x,代碼行數:33,代碼來源:dispatcher.test.php

示例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);
 }
開發者ID:evrard,項目名稱:cakephp2x,代碼行數:99,代碼來源:dispatcher.test.php


注:本文中的Dispatcher::cached方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。