Skip to content

Commit

Permalink
Mock CakeResponse
Browse files Browse the repository at this point in the history
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 b081ef5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/Cake/TestSuite/ControllerTestCase.php
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit b081ef5

Please sign in to comment.