Clear the router state after testAction().

When using array urls, internal state in the Router would cause requests
to be incorrectly handled causing multiple testAction calls in a single
test to fail. By reloading the router we start off with a clean slate
each time.

Refs #8480
This commit is contained in:
mark_story 2016-03-19 12:16:21 -04:00
parent 01d3c2f599
commit 7ceb0993bf

View file

@ -278,6 +278,10 @@ abstract class ControllerTestCase extends CakeTestCase {
$Dispatch->testController = $this->controller;
$Dispatch->response = $this->getMock('CakeResponse', array('send', '_clearBuffer'));
$this->result = $Dispatch->dispatch($request, $Dispatch->response, $params);
// Clear out any stored requests.
Router::reload();
$this->controller = $Dispatch->testController;
$this->vars = $this->controller->viewVars;
$this->contents = $this->controller->response->body();