Skip to content

Commit 4a98f28

Browse files
committed
feature #15697 [BrowserKit] Added isFollowingRedirects and getMaxRedirects methods (Naktibalda)
This PR was submitted for the 2.3 branch but it was merged into the 2.8 branch instead (closes #15697). Discussion ---------- [BrowserKit] Added isFollowingRedirects and getMaxRedirects methods | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- b475607 [BrowserKit] Added isFollowingRedirects and getMaxRedirects methods
2 parents 4fcf136 + b475607 commit 4a98f28

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy