Browse Source

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.
Mark Story 9 years ago
parent
commit
24294fa4db

+ 1 - 1
src/Controller/Controller.php

@@ -540,7 +540,7 @@ class Controller implements EventListenerInterface, EventDispatcherInterface
 
         $response = $this->response;
         if ($status) {
-            $response->statusCode($status);
+            $response = $response->withStatus($status);
         }
 
         $event = $this->dispatchEvent('Controller.beforeRedirect', [$url, $response]);

+ 1 - 3
src/TestSuite/LegacyRequestDispatcher.php

@@ -51,8 +51,6 @@ class LegacyRequestDispatcher
             ['priority' => 999],
             [$this->_test, 'controllerSpy']
         );
-        $dispatcher->dispatch($request, $response);
-
-        return $response;
+        return $dispatcher->dispatch($request, $response);
     }
 }

+ 2 - 1
src/TestSuite/Stub/Response.php

@@ -24,7 +24,7 @@ class Response extends Base
     /**
      * Stub the send() method so headers and output are not sent.
      *
-     * @return void
+     * @return $this
      */
     public function send()
     {
@@ -32,5 +32,6 @@ class Response extends Base
             $this->statusCode(302);
         }
         $this->_setContentType();
+        return $this;
     }
 }