Skip to content

Commit

Permalink
Clear the router state after testAction().
Browse files Browse the repository at this point in the history
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
  • Loading branch information
markstory committed Mar 19, 2016
1 parent 01d3c2f commit 7ceb099
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Cake/TestSuite/ControllerTestCase.php
Expand Up @@ -278,6 +278,10 @@ protected function _testAction($url, $options = array()) {
$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();
Expand Down

0 comments on commit 7ceb099

Please sign in to comment.