Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b475607

Browse files
Naktibaldafabpot
authored andcommitted
[BrowserKit] Added isFollowingRedirects and getMaxRedirects methods
1 parent 4fcf136 commit b475607

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ public function followRedirects($followRedirect = true)
7474
$this->followRedirects = (bool) $followRedirect;
7575
}
7676

77+
/**
78+
* Returns whether client automatically follows redirects or not.
79+
*
80+
* @return bool
81+
*/
82+
public function isFollowingRedirects()
83+
{
84+
return $this->followRedirects;
85+
}
86+
7787
/**
7888
* Sets the maximum number of requests that crawler can follow.
7989
*
@@ -85,6 +95,16 @@ public function setMaxRedirects($maxRedirects)
8595
$this->followRedirects = -1 != $this->maxRedirects;
8696
}
8797

98+
/**
99+
* Returns the maximum number of requests that crawler can follow.
100+
*
101+
* @return int
102+
*/
103+
public function getMaxRedirects()
104+
{
105+
return $this->maxRedirects;
106+
}
107+
88108
/**
89109
* Sets the insulated flag.
90110
*

src/Symfony/Component/BrowserKit/Tests/ClientTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,22 @@ public function testFollowRedirectWithPort()
492492
$this->assertEquals($headers, $client->getRequest()->getServer());
493493
}
494494

495+
public function testIsFollowingRedirects()
496+
{
497+
$client = new TestClient();
498+
$this->assertTrue($client->isFollowingRedirects(), '->getFollowRedirects() returns default value');
499+
$client->followRedirects(false);
500+
$this->assertFalse($client->isFollowingRedirects(), '->getFollowRedirects() returns assigned value');
501+
}
502+
503+
public function testGetMaxRedirects()
504+
{
505+
$client = new TestClient();
506+
$this->assertEquals(-1, $client->getMaxRedirects(), '->getMaxRedirects() returns default value');
507+
$client->setMaxRedirects(3);
508+
$this->assertEquals(3, $client->getMaxRedirects(), '->getMaxRedirects() returns assigned value');
509+
}
510+
495511
public function testBack()
496512
{
497513
$client = new TestClient();

0 commit comments

Comments
 (0)