From 030ee312113becfda7a34e3f22c92215f714b189 Mon Sep 17 00:00:00 2001 From: Jonny Wenmoth Date: Tue, 2 Feb 2016 21:59:52 +1300 Subject: [PATCH] Redirect URL is always blank due to wrong case - https://github.com/jonnnnyw/php-phantomjs/issues/64 --- src/JonnyW/PhantomJs/Http/Response.php | 4 ++-- .../Tests/Integration/ClientTest.php | 22 +++++++++++++++++++ .../Tests/Unit/Http/ResponseTest.php | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/JonnyW/PhantomJs/Http/Response.php b/src/JonnyW/PhantomJs/Http/Response.php index 6a89424..9ec5291 100644 --- a/src/JonnyW/PhantomJs/Http/Response.php +++ b/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 @@ public function getUrl() */ public function getRedirectUrl() { - return $this->redirectUrl; + return $this->redirectURL; } /** diff --git a/src/JonnyW/PhantomJs/Tests/Integration/ClientTest.php b/src/JonnyW/PhantomJs/Tests/Integration/ClientTest.php index cfb8d35..ee7792f 100644 --- a/src/JonnyW/PhantomJs/Tests/Integration/ClientTest.php +++ b/src/JonnyW/PhantomJs/Tests/Integration/ClientTest.php @@ -243,6 +243,28 @@ public function testResponseContainsHeaders() $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. diff --git a/src/JonnyW/PhantomJs/Tests/Unit/Http/ResponseTest.php b/src/JonnyW/PhantomJs/Tests/Unit/Http/ResponseTest.php index 931eff2..94c6837 100644 --- a/src/JonnyW/PhantomJs/Tests/Unit/Http/ResponseTest.php +++ b/src/JonnyW/PhantomJs/Tests/Unit/Http/ResponseTest.php @@ -103,7 +103,7 @@ public function testUrlCanBeImported() public function testRedirectUrlCanBeImported() { $data = array( - 'redirectUrl' => 'http://test.com' + 'redirectURL' => 'http://test.com' ); $response = $this->getResponse();