mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge pull request #5473 from cakephp/2.7-test
Backport array support for testAction()
This commit is contained in:
commit
14dc6cef6b
2 changed files with 17 additions and 2 deletions
|
@ -299,6 +299,17 @@ class ControllerTestCaseTest extends CakeTestCase {
|
||||||
$this->assertEquals($expected, $results);
|
$this->assertEquals($expected, $results);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test array URLs with testAction()
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testTestActionArrayUrls() {
|
||||||
|
$Controller = $this->Case->generate('TestsApps');
|
||||||
|
$this->Case->testAction(array('controller' => 'tests_apps', 'action' => 'index'));
|
||||||
|
$this->assertInternalType('array', $this->Case->controller->viewVars);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make sure testAction() can hit plugin controllers.
|
* Make sure testAction() can hit plugin controllers.
|
||||||
*
|
*
|
||||||
|
|
|
@ -210,12 +210,12 @@ abstract class ControllerTestCase extends CakeTestCase {
|
||||||
* - `result` Get the return value of the controller action. Useful
|
* - `result` Get the return value of the controller action. Useful
|
||||||
* for testing requestAction methods.
|
* for testing requestAction methods.
|
||||||
*
|
*
|
||||||
* @param string $url The url to test
|
* @param string|array $url The URL to test.
|
||||||
* @param array $options See options
|
* @param array $options See options
|
||||||
* @return mixed The specified return type.
|
* @return mixed The specified return type.
|
||||||
* @triggers ControllerTestCase $Dispatch, array('request' => $request)
|
* @triggers ControllerTestCase $Dispatch, array('request' => $request)
|
||||||
*/
|
*/
|
||||||
protected function _testAction($url = '', $options = array()) {
|
protected function _testAction($url, $options = array()) {
|
||||||
$this->vars = $this->result = $this->view = $this->contents = $this->headers = null;
|
$this->vars = $this->result = $this->view = $this->contents = $this->headers = null;
|
||||||
|
|
||||||
$options += array(
|
$options += array(
|
||||||
|
@ -224,6 +224,10 @@ abstract class ControllerTestCase extends CakeTestCase {
|
||||||
'return' => 'result'
|
'return' => 'result'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (is_array($url)) {
|
||||||
|
$url = Router::url($url);
|
||||||
|
}
|
||||||
|
|
||||||
$restore = array('get' => $_GET, 'post' => $_POST);
|
$restore = array('get' => $_GET, 'post' => $_POST);
|
||||||
|
|
||||||
$_SERVER['REQUEST_METHOD'] = strtoupper($options['method']);
|
$_SERVER['REQUEST_METHOD'] = strtoupper($options['method']);
|
||||||
|
|
Loading…
Reference in a new issue