Skip to content
Permalink
Browse files

Mock CakeResponse

Ability to set the class name to use for mocking the response object
  • Loading branch information...
felixmaier1989 committed Apr 19, 2016
1 parent dec2910 commit b081ef5a386b9b0b7a5ee28b7617d5bfb0284769
Showing with 9 additions and 2 deletions.
  1. +9 −2 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 @@ protected function _testAction($url, $options = array()) {
$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 @@ public function generate($controller, $mocks = array()) {
$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);

0 comments on commit b081ef5

Please sign in to comment.
You can’t perform that action at this time.