|
21 | 21 | * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License |
22 | 22 | */ |
23 | 23 | App::import('Core', array('View', 'Controller')); |
| 24 | +App::import('Helper', 'Cache'); |
| 25 | + |
| 26 | +Mock::generate('Helper', 'CallbackMockHelper'); |
| 27 | +Mock::generate('CacheHelper', 'ViewTestMockCacheHelper'); |
24 | 28 |
|
25 | 29 | if (!class_exists('ErrorHandler')) { |
26 | 30 | App::import('Core', array('Error')); |
27 | 31 | } |
28 | | -if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) { |
29 | | - define('CAKEPHP_UNIT_TEST_EXECUTION', 1); |
30 | | -} |
31 | 32 |
|
32 | 33 | /** |
33 | 34 | * ViewPostsController class |
@@ -203,7 +204,7 @@ function afterLayout() { |
203 | 204 | $View->output .= 'modified in the afterlife'; |
204 | 205 | } |
205 | 206 | } |
206 | | -Mock::generate('Helper', 'CallbackMockHelper'); |
| 207 | + |
207 | 208 |
|
208 | 209 | /** |
209 | 210 | * ViewTest class |
@@ -698,6 +699,27 @@ function testRender() { |
698 | 699 | $this->assertPattern("/<div id=\"content\">posts index<\/div>/", $result); |
699 | 700 | } |
700 | 701 |
|
| 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 | + |
701 | 723 | /** |
702 | 724 | * testGetViewFileName method |
703 | 725 | * |
|
0 commit comments