Skip to content

Commit

Permalink
Split up tests.
Browse files Browse the repository at this point in the history
Fix API usage in tests.
  • Loading branch information
markstory committed May 15, 2012
1 parent cbd6caf commit 0faaedf
Showing 1 changed file with 20 additions and 32 deletions.
52 changes: 20 additions & 32 deletions lib/Cake/Test/Case/View/Helper/CacheHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,14 @@ public function testComplexNoCache() {
*/
public function testCacheViewVars() {
$this->Controller->cache_parsing();
$this->Controller->params = array(
$this->Controller->request->addParams(array(
'controller' => 'cache_test',
'action' => 'cache_parsing',
'pass' => array(),
'named' => array()
);
));
$this->Controller->request->here = '/cacheTest/cache_parsing';
$this->Controller->cacheAction = 21600;
$this->Controller->here = '/cacheTest/cache_parsing';
$this->Controller->action = 'cache_parsing';

$View = new View($this->Controller);
$result = $View->render('index');
Expand All @@ -323,21 +322,20 @@ public function testCacheViewVars() {
* @return void
*/
public function testCacheCallbacks() {
$this->Controller->cache_parsing();
$this->Controller->params = array(
$this->Controller->request->addParams(array(
'controller' => 'cache_test',
'action' => 'cache_parsing',
'pass' => array(),
'named' => array()
);
));
$this->Controller->cacheAction = array(
'cache_parsing' => array(
'duration' => 21600,
'callbacks' => true
)
);
$this->Controller->here = '/cacheTest/cache_parsing';
$this->Controller->action = 'cache_parsing';
$this->Controller->request->here = '/cacheTest/cache_parsing';
$this->Controller->cache_parsing();

$View = new View($this->Controller);
$result = $View->render('index');
Expand All @@ -358,58 +356,47 @@ public function testCacheCallbacks() {
* @return void
*/
public function testCacheActionArray() {
$this->Controller->cache_parsing();
$this->Controller->request->addParams(array(
'controller' => 'cache_test',
'action' => 'cache_parsing',
'pass' => array(),
'named' => array()
));
$this->Controller->request->here = '/cache_test/cache_parsing';
$this->Controller->cacheAction = array(
'cache_parsing' => 21600
);
$this->Controller->request->here = '/cache_test/cache_parsing';
$this->Controller->action = '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.php';
$this->assertTrue(file_exists($filename));
@unlink($filename);

$this->Controller->cache_parsing();
$this->Controller->cacheAction = array(
'cache_parsing' => 21600
);
$this->Controller->request->here = '/cacheTest/cache_parsing';
$this->Controller->action = '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 . 'cachetest_cache_parsing.php';
$filename = CACHE . 'views' . DS . 'cache_test_cache_parsing.php';
$this->assertTrue(file_exists($filename));
@unlink($filename);
}

$this->Controller->cache_parsing();
/**
* Test that cacheAction works with camelcased controller names.
*
* @return void
*/
public function testCacheActionArrayCamelCase() {
$this->Controller->request->addParams(array(
'controller' => 'cache_test',
'action' => 'cache_parsing',
'pass' => array(),
'named' => array()
));
$this->Controller->cacheAction = array(
'some_other_action' => 21600
'cache_parsing' => 21600
);
$this->Controller->request->here = '/cacheTest/cache_parsing';
$this->Controller->action = 'cache_parsing';
$this->Controller->cache_parsing();

$View = new View($this->Controller);
$result = $View->render('index');
Expand All @@ -418,7 +405,8 @@ public function testCacheActionArray() {
$this->assertNotRegExp('/php echo/', $result);

$filename = CACHE . 'views' . DS . 'cachetest_cache_parsing.php';
$this->assertFalse(file_exists($filename));
$this->assertTrue(file_exists($filename));
@unlink($filename);
}

/**
Expand Down

0 comments on commit 0faaedf

Please sign in to comment.