Просмотр исходного кода

Redirect URL is always blank due to wrong case - https://github.com/jonnnnyw/php-phantomjs/issues/64

Jonny Wenmoth 10 лет назад
Родитель
Сommit
030ee31211

+ 2 - 2
src/JonnyW/PhantomJs/Http/Response.php

@@ -64,7 +64,7 @@ class Response
      * @var string
      * @access public
      */
-    public $redirectUrl;
+    public $redirectURL;
 
     /**
      * Request time string
@@ -209,7 +209,7 @@ class Response
      */
     public function getRedirectUrl()
     {
-        return $this->redirectUrl;
+        return $this->redirectURL;
     }
 
     /**

+ 22 - 0
src/JonnyW/PhantomJs/Tests/Integration/ClientTest.php

@@ -243,6 +243,28 @@ EOF;
 
         $this->assertNotEmpty($response->getHeaders());
     }
+    
+    /**
+     * Test redirect URL is set in response
+     * if request is redirected.
+     *
+     * @access public
+     * @return void
+     */
+    public function testRedirectUrlIsSetInResponseIfRequestIsRedirected()
+    {
+        $client = $this->getClient();
+
+        $request  = $client->getMessageFactory()->createRequest();
+        $response = $client->getMessageFactory()->createResponse();
+
+        $request->setMethod('GET');
+        $request->setUrl('https://jigsaw.w3.org/HTTP/300/302.html');
+
+        $client->send($request, $response);
+
+        $this->assertNotEmpty($response->getRedirectUrl());
+    }
 
     /**
      * Test POST request sends request data.

+ 1 - 1
src/JonnyW/PhantomJs/Tests/Unit/Http/ResponseTest.php

@@ -103,7 +103,7 @@ class ResponseTest extends \PHPUnit_Framework_TestCase
     public function testRedirectUrlCanBeImported()
     {
         $data = array(
-            'redirectUrl' => 'http://test.com'
+            'redirectURL' => 'http://test.com'
         );
 
         $response = $this->getResponse();