Browse Source

Cleanup redirect().

Mark Scherer 10 years ago
parent
commit
be1e20c896
2 changed files with 3 additions and 5 deletions
  1. 1 1
      src/Controller/Controller.php
  2. 2 4
      tests/TestCase/Controller/ControllerTest.php

+ 1 - 1
src/Controller/Controller.php

@@ -524,7 +524,7 @@ class Controller implements EventListenerInterface, EventDispatcherInterface
             return;
         }
 
-        if ($url !== null && !$response->location()) {
+        if (!$response->location()) {
             $response->location(Router::url($url, true));
         }
 

+ 2 - 4
tests/TestCase/Controller/ControllerTest.php

@@ -464,8 +464,7 @@ class ControllerTest extends TestCase
      */
     public function testRedirectByCode($code, $msg)
     {
-        $Controller = new Controller(null);
-        $Controller->response = new Response();
+        $Controller = new Controller(null, new Response());
 
         $response = $Controller->redirect('http://cakephp.org', (int)$code, false);
         $this->assertEquals($code, $response->statusCode());
@@ -480,8 +479,7 @@ class ControllerTest extends TestCase
      */
     public function testRedirectBeforeRedirectModifyingUrl()
     {
-        $Controller = new Controller(null);
-        $Controller->response = new Response();
+        $Controller = new Controller(null, new Response());
 
         $Controller->eventManager()->attach(function ($event, $url, $response) {
             $response->location('http://book.cakephp.org');