mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Mock CakeResponse
Ability to set the class name to use for mocking the response object
This commit is contained in:
parent
dec291061a
commit
b081ef5a38
1 changed files with 9 additions and 2 deletions
|
@ -178,6 +178,13 @@ abstract class ControllerTestCase extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
protected $_dirtyController = false;
|
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
|
* Used to enable calling ControllerTestCase::testAction() without the testing
|
||||||
* framework thinking that it's a test case
|
* framework thinking that it's a test case
|
||||||
|
@ -276,7 +283,7 @@ abstract class ControllerTestCase extends CakeTestCase {
|
||||||
$params['requested'] = 1;
|
$params['requested'] = 1;
|
||||||
}
|
}
|
||||||
$Dispatch->testController = $this->controller;
|
$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);
|
$this->result = $Dispatch->dispatch($request, $Dispatch->response, $params);
|
||||||
|
|
||||||
// Clear out any stored requests.
|
// Clear out any stored requests.
|
||||||
|
@ -345,7 +352,7 @@ abstract class ControllerTestCase extends CakeTestCase {
|
||||||
$controllerObj = $this->getMock($name . 'Controller', $mocks['methods'], array(), '', false);
|
$controllerObj = $this->getMock($name . 'Controller', $mocks['methods'], array(), '', false);
|
||||||
$controllerObj->name = $name;
|
$controllerObj->name = $name;
|
||||||
$request = $this->getMock('CakeRequest');
|
$request = $this->getMock('CakeRequest');
|
||||||
$response = $this->getMock('CakeResponse', array('_sendHeader'));
|
$response = $this->getMock($this->_responseClass, array('_sendHeader'));
|
||||||
$controllerObj->__construct($request, $response);
|
$controllerObj->__construct($request, $response);
|
||||||
$controllerObj->Components->setController($controllerObj);
|
$controllerObj->Components->setController($controllerObj);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue