From b47560773e8694831cf28ac7466016f1d3354d06 Mon Sep 17 00:00:00 2001 From: Gintautas Miselis Date: Fri, 4 Sep 2015 23:25:23 +0100 Subject: [PATCH] [BrowserKit] Added isFollowingRedirects and getMaxRedirects methods --- src/Symfony/Component/BrowserKit/Client.php | 20 +++++++++++++++++++ .../Component/BrowserKit/Tests/ClientTest.php | 16 +++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index f41f156ac4ce..4e37d5ac7361 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -74,6 +74,16 @@ public function followRedirects($followRedirect = true) $this->followRedirects = (bool) $followRedirect; } + /** + * Returns whether client automatically follows redirects or not. + * + * @return bool + */ + public function isFollowingRedirects() + { + return $this->followRedirects; + } + /** * Sets the maximum number of requests that crawler can follow. * @@ -85,6 +95,16 @@ public function setMaxRedirects($maxRedirects) $this->followRedirects = -1 != $this->maxRedirects; } + /** + * Returns the maximum number of requests that crawler can follow. + * + * @return int + */ + public function getMaxRedirects() + { + return $this->maxRedirects; + } + /** * Sets the insulated flag. * diff --git a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php index cc7db71fd2f9..709d8b933af5 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php @@ -492,6 +492,22 @@ public function testFollowRedirectWithPort() $this->assertEquals($headers, $client->getRequest()->getServer()); } + public function testIsFollowingRedirects() + { + $client = new TestClient(); + $this->assertTrue($client->isFollowingRedirects(), '->getFollowRedirects() returns default value'); + $client->followRedirects(false); + $this->assertFalse($client->isFollowingRedirects(), '->getFollowRedirects() returns assigned value'); + } + + public function testGetMaxRedirects() + { + $client = new TestClient(); + $this->assertEquals(-1, $client->getMaxRedirects(), '->getMaxRedirects() returns default value'); + $client->setMaxRedirects(3); + $this->assertEquals(3, $client->getMaxRedirects(), '->getMaxRedirects() returns assigned value'); + } + public function testBack() { $client = new TestClient();