Permalink
Browse files

Adding tests for CacheHelper triggering. Was broken by previous refac…

…toring.
  • Loading branch information...
1 parent 01cf40b commit 8cf7dbbbfa6bc61faf546823ab8e7f67ed4267e0 @markstory markstory committed Sep 15, 2009
Showing with 26 additions and 4 deletions.
  1. +26 −4 cake/tests/cases/libs/view/view.test.php
@@ -21,13 +21,14 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
App::import('Core', array('View', 'Controller'));
+App::import('Helper', 'Cache');
+
+Mock::generate('Helper', 'CallbackMockHelper');
+Mock::generate('CacheHelper', 'ViewTestMockCacheHelper');
if (!class_exists('ErrorHandler')) {
App::import('Core', array('Error'));
}
-if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
- define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
-}
/**
* ViewPostsController class
@@ -203,7 +204,7 @@ function afterLayout() {
$View->output .= 'modified in the afterlife';
}
}
-Mock::generate('Helper', 'CallbackMockHelper');
+
/**
* ViewTest class
@@ -699,6 +700,27 @@ function testRender() {
}
/**
+ * test rendering layout with cache helper loaded
+ *
+ * @return void
+ **/
+ function testRenderLayoutWithMockCacheHelper() {
+ $_check = Configure::read('Cache.check');
+ Configure::write('Cache.check', true);
+
+ $Controller = new ViewPostsController();
+ $Controller->cacheAction = '1 day';
+ $View = new View($Controller);
+ $View->loaded['cache'] = new ViewTestMockCacheHelper();
+ $View->loaded['cache']->expectCallCount('cache', 2);
+
+ $result = $View->render('index');
+ $this->assertPattern('/posts index/', $result);
+
+ Configure::write('Cache.check', $_check);
+ }
+
+/**
* testGetViewFileName method
*
* @access public

0 comments on commit 8cf7dbb

Please sign in to comment.