From b081ef5a386b9b0b7a5ee28b7617d5bfb0284769 Mon Sep 17 00:00:00 2001 From: felixmaier1989 Date: Tue, 19 Apr 2016 14:50:40 +0700 Subject: [PATCH] Mock CakeResponse Ability to set the class name to use for mocking the response object --- lib/Cake/TestSuite/ControllerTestCase.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/Cake/TestSuite/ControllerTestCase.php b/lib/Cake/TestSuite/ControllerTestCase.php index 020fcfe2c..51f6f1d8a 100644 --- a/lib/Cake/TestSuite/ControllerTestCase.php +++ b/lib/Cake/TestSuite/ControllerTestCase.php @@ -177,6 +177,13 @@ abstract class ControllerTestCase extends CakeTestCase { * @var bool */ protected $_dirtyController = false; + +/** + * The class name to use for mocking the response object. + * + * @var string + */ + protected $_responseClass = 'CakeResponse'; /** * Used to enable calling ControllerTestCase::testAction() without the testing @@ -276,7 +283,7 @@ abstract class ControllerTestCase extends CakeTestCase { $params['requested'] = 1; } $Dispatch->testController = $this->controller; - $Dispatch->response = $this->getMock('CakeResponse', array('send', '_clearBuffer')); + $Dispatch->response = $this->getMock($this->_responseClass, array('send', '_clearBuffer')); $this->result = $Dispatch->dispatch($request, $Dispatch->response, $params); // Clear out any stored requests. @@ -345,7 +352,7 @@ abstract class ControllerTestCase extends CakeTestCase { $controllerObj = $this->getMock($name . 'Controller', $mocks['methods'], array(), '', false); $controllerObj->name = $name; $request = $this->getMock('CakeRequest'); - $response = $this->getMock('CakeResponse', array('_sendHeader')); + $response = $this->getMock($this->_responseClass, array('_sendHeader')); $controllerObj->__construct($request, $response); $controllerObj->Components->setController($controllerObj);