Skip to content

Commit

Permalink
Adding test for CacheHelper.
Browse files Browse the repository at this point in the history
Refs #2381
  • Loading branch information
markstory committed Dec 17, 2011
1 parent 78325a1 commit a71b0f9
Showing 1 changed file with 32 additions and 13 deletions.
45 changes: 32 additions & 13 deletions lib/Cake/Test/Case/View/Helper/CacheHelperTest.php
Expand Up @@ -109,7 +109,6 @@ public function testLayoutCacheParsingNoTagsInView() {
$this->Controller->request->addParams(array( $this->Controller->request->addParams(array(
'controller' => 'cache_test', 'controller' => 'cache_test',
'action' => 'cache_parsing', 'action' => 'cache_parsing',
'url' => array(),
'pass' => array(), 'pass' => array(),
'named' => array() 'named' => array()
)); ));
Expand Down Expand Up @@ -143,7 +142,6 @@ public function testCacheNonLatinCharactersInRoute() {
$this->Controller->request->addParams(array( $this->Controller->request->addParams(array(
'controller' => 'cache_test', 'controller' => 'cache_test',
'action' => 'cache_parsing', 'action' => 'cache_parsing',
'url' => array(),
'pass' => array('風街ろまん'), 'pass' => array('風街ろまん'),
'named' => array() 'named' => array()
)); ));
Expand All @@ -170,7 +168,6 @@ public function testLayoutCacheParsingWithTagsInView() {
$this->Controller->request->addParams(array( $this->Controller->request->addParams(array(
'controller' => 'cache_test', 'controller' => 'cache_test',
'action' => 'cache_parsing', 'action' => 'cache_parsing',
'url' => array(),
'pass' => array(), 'pass' => array(),
'named' => array() 'named' => array()
)); ));
Expand Down Expand Up @@ -205,7 +202,6 @@ public function testMultipleNoCacheTagsInViewfile() {
$this->Controller->request->addParams(array( $this->Controller->request->addParams(array(
'controller' => 'cache_test', 'controller' => 'cache_test',
'action' => 'cache_parsing', 'action' => 'cache_parsing',
'url' => array(),
'pass' => array(), 'pass' => array(),
'named' => array() 'named' => array()
)); ));
Expand Down Expand Up @@ -237,7 +233,6 @@ public function testComplexNoCache () {
$this->Controller->request->addParams(array( $this->Controller->request->addParams(array(
'controller' => 'cache_test', 'controller' => 'cache_test',
'action' => 'cache_complex', 'action' => 'cache_complex',
'url' => array(),
'pass' => array(), 'pass' => array(),
'named' => array() 'named' => array()
)); ));
Expand Down Expand Up @@ -298,7 +293,6 @@ public function testCacheViewVars() {
$this->Controller->params = array( $this->Controller->params = array(
'controller' => 'cache_test', 'controller' => 'cache_test',
'action' => 'cache_parsing', 'action' => 'cache_parsing',
'url' => array(),
'pass' => array(), 'pass' => array(),
'named' => array() 'named' => array()
); );
Expand Down Expand Up @@ -332,7 +326,6 @@ public function testCacheCallbacks() {
$this->Controller->params = array( $this->Controller->params = array(
'controller' => 'cache_test', 'controller' => 'cache_test',
'action' => 'cache_parsing', 'action' => 'cache_parsing',
'url' => array(),
'pass' => array(), 'pass' => array(),
'named' => array() 'named' => array()
); );
Expand Down Expand Up @@ -368,7 +361,6 @@ public function testCacheActionArray() {
$this->Controller->request->addParams(array( $this->Controller->request->addParams(array(
'controller' => 'cache_test', 'controller' => 'cache_test',
'action' => 'cache_parsing', 'action' => 'cache_parsing',
'url' => array(),
'pass' => array(), 'pass' => array(),
'named' => array() 'named' => array()
)); ));
Expand Down Expand Up @@ -411,7 +403,6 @@ public function testCacheActionArray() {
$this->Controller->request->addParams(array( $this->Controller->request->addParams(array(
'controller' => 'cache_test', 'controller' => 'cache_test',
'action' => 'cache_parsing', 'action' => 'cache_parsing',
'url' => array(),
'pass' => array(), 'pass' => array(),
'named' => array() 'named' => array()
)); ));
Expand Down Expand Up @@ -443,7 +434,6 @@ public function testCacheWithNamedAndPassedArgs() {
$this->Controller->request->addParams(array( $this->Controller->request->addParams(array(
'controller' => 'cache_test', 'controller' => 'cache_test',
'action' => 'cache_parsing', 'action' => 'cache_parsing',
'url' => array(),
'pass' => array(1, 2), 'pass' => array(1, 2),
'named' => array( 'named' => array(
'name' => 'mark', 'name' => 'mark',
Expand All @@ -466,6 +456,38 @@ public function testCacheWithNamedAndPassedArgs() {
@unlink($filename); @unlink($filename);
} }


/**
* Test that query string parameters are included in the cache filename.
*
* @return void
*/
public function testCacheWithQueryStringParams() {
Router::reload();

$this->Controller->cache_parsing();
$this->Controller->request->addParams(array(
'controller' => 'cache_test',
'action' => 'cache_parsing',
'pass' => array(),
'named' => array()
));
$this->Controller->request->query = array('q' => 'cakephp');
$this->Controller->cacheAction = array(
'cache_parsing' => 21600
);
$this->Controller->request->here = '/cache_test/cache_parsing';

$View = new View($this->Controller);
$result = $View->render('index');

$this->assertNotRegExp('/cake:nocache/', $result);
$this->assertNotRegExp('/php echo/', $result);

$filename = CACHE . 'views' . DS . 'cache_test_cache_parsing_q_cakephp.php';
$this->assertTrue(file_exists($filename), 'Missing cache file ' . $filename);
@unlink($filename);
}

/** /**
* test that custom routes are respected when generating cache files. * test that custom routes are respected when generating cache files.
* *
Expand All @@ -480,7 +502,6 @@ public function testCacheWithCustomRoutes() {
'lang' => 'en', 'lang' => 'en',
'controller' => 'cache_test', 'controller' => 'cache_test',
'action' => 'cache_parsing', 'action' => 'cache_parsing',
'url' => array(),
'pass' => array(), 'pass' => array(),
'named' => array() 'named' => array()
)); ));
Expand Down Expand Up @@ -518,7 +539,6 @@ public function testCacheBaseNameControllerName() {
$this->Controller->params = array( $this->Controller->params = array(
'controller' => 'cacheTest', 'controller' => 'cacheTest',
'action' => 'cache_name', 'action' => 'cache_name',
'url' => array(),
'pass' => array(), 'pass' => array(),
'named' => array() 'named' => array()
); );
Expand Down Expand Up @@ -597,7 +617,6 @@ public function testCacheEmptySections() {
$this->Controller->params = array( $this->Controller->params = array(
'controller' => 'cacheTest', 'controller' => 'cacheTest',
'action' => 'cache_empty_sections', 'action' => 'cache_empty_sections',
'url' => array(),
'pass' => array(), 'pass' => array(),
'named' => array() 'named' => array()
); );
Expand Down

0 comments on commit a71b0f9

Please sign in to comment.