Skip to content

Commit 8cf7dbb

Browse files
committed
Adding tests for CacheHelper triggering. Was broken by previous refactoring.
1 parent 01cf40b commit 8cf7dbb

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

cake/tests/cases/libs/view/view.test.php

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
2222
*/
2323
App::import('Core', array('View', 'Controller'));
24+
App::import('Helper', 'Cache');
25+
26+
Mock::generate('Helper', 'CallbackMockHelper');
27+
Mock::generate('CacheHelper', 'ViewTestMockCacheHelper');
2428

2529
if (!class_exists('ErrorHandler')) {
2630
App::import('Core', array('Error'));
2731
}
28-
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
29-
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
30-
}
3132

3233
/**
3334
* ViewPostsController class
@@ -203,7 +204,7 @@ function afterLayout() {
203204
$View->output .= 'modified in the afterlife';
204205
}
205206
}
206-
Mock::generate('Helper', 'CallbackMockHelper');
207+
207208

208209
/**
209210
* ViewTest class
@@ -698,6 +699,27 @@ function testRender() {
698699
$this->assertPattern("/<div id=\"content\">posts index<\/div>/", $result);
699700
}
700701

702+
/**
703+
* test rendering layout with cache helper loaded
704+
*
705+
* @return void
706+
**/
707+
function testRenderLayoutWithMockCacheHelper() {
708+
$_check = Configure::read('Cache.check');
709+
Configure::write('Cache.check', true);
710+
711+
$Controller = new ViewPostsController();
712+
$Controller->cacheAction = '1 day';
713+
$View = new View($Controller);
714+
$View->loaded['cache'] = new ViewTestMockCacheHelper();
715+
$View->loaded['cache']->expectCallCount('cache', 2);
716+
717+
$result = $View->render('index');
718+
$this->assertPattern('/posts index/', $result);
719+
720+
Configure::write('Cache.check', $_check);
721+
}
722+
701723
/**
702724
* testGetViewFileName method
703725
*

0 commit comments

Comments
 (0)