Skip to content
Permalink
Browse files

Update Controller::redirect() as well.

In addition to the Controller method, fixup the Stub\Response to work
better with PSR7 responses. By returning $this, we can start using
immutable methods and not adversely effect tests. Without this if people
used immutable methods their tests would start failing.
  • Loading branch information...
markstory committed Oct 27, 2016
1 parent 549cb20 commit 24294fa4db4c4fe0a87da5759f60bc15008f8485
Showing with 4 additions and 5 deletions.
  1. +1 −1 src/Controller/Controller.php
  2. +1 −3 src/TestSuite/LegacyRequestDispatcher.php
  3. +2 −1 src/TestSuite/Stub/Response.php
@@ -540,7 +540,7 @@ public function redirect($url, $status = 302)
$response = $this->response;
if ($status) {
$response->statusCode($status);
$response = $response->withStatus($status);
}
$event = $this->dispatchEvent('Controller.beforeRedirect', [$url, $response]);
@@ -51,8 +51,6 @@ public function execute($request)
['priority' => 999],
[$this->_test, 'controllerSpy']
);
$dispatcher->dispatch($request, $response);
return $response;
return $dispatcher->dispatch($request, $response);
}
}
@@ -24,13 +24,14 @@ class Response extends Base
/**
* Stub the send() method so headers and output are not sent.
*
* @return void
* @return $this
*/
public function send()
{
if (isset($this->_headers['Location']) && $this->_status === 200) {
$this->statusCode(302);
}
$this->_setContentType();
return $this;
}
}

0 comments on commit 24294fa

Please sign in to comment.
You can’t perform that action at this time.