Fixing View test case to be compatible with PHPUnit

This commit is contained in:
José Lorenzo Rodríguez 2010-05-09 16:09:02 -04:30
parent b8e83e6a49
commit d252fdeb52

View file

@ -20,9 +20,6 @@
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'));
}
@ -608,14 +605,15 @@ class ViewTest extends CakeTestCase {
* @return void
*/
function testHelperCallbackTriggering() {
$mockHelper = $this->getMock('Helper', array(), array(), 'CallbackMockHelper');
$this->PostsController->helpers = array('Session', 'Html', 'CallbackMock');
$View = new TestView($this->PostsController);
$loaded = array();
$View->loaded = $View->loadHelpers($loaded, $this->PostsController->helpers);
$View->loaded['CallbackMock']->expectOnce('beforeRender');
$View->loaded['CallbackMock']->expectOnce('afterRender');
$View->loaded['CallbackMock']->expectOnce('beforeLayout');
$View->loaded['CallbackMock']->expectOnce('afterLayout');
$View->loaded['CallbackMock']->expects($this->once())->method('beforeRender');
$View->loaded['CallbackMock']->expects($this->once())->method('afterRender');
$View->loaded['CallbackMock']->expects($this->once())->method('beforeLayout');
$View->loaded['CallbackMock']->expects($this->once())->method('afterLayout');
$View->render('index');
}
@ -745,8 +743,8 @@ class ViewTest extends CakeTestCase {
$Controller = new ViewPostsController();
$Controller->cacheAction = '1 day';
$View = new View($Controller);
$View->loaded['cache'] = new ViewTestMockCacheHelper();
$View->loaded['cache']->expectCallCount('cache', 2);
$View->loaded['cache'] = $this->getMock('CacheHelper');
$View->loaded['cache']->expects($this->exactly(2))->method('cache');
$result = $View->render('index');
$this->assertPattern('/posts index/', $result);