8000 [BrowserKit] Added isFollowingRedirects and getMaxRedirects methods by Naktibalda · Pull Request #15697 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[BrowserKit] Added isFollowingRedirects and getMaxRedirects methods #15697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
< 8000 svg style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" aria-hidden="true" data-view-component="true" class="flex-1 anim-rotate"> Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/Symfony/Component/BrowserKit/Client.php
C557
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,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.
*
Expand All @@ -90,6 +100,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.
*
Expand Down
16 changes: 16 additions & 0 deletions src/Symfony/Component/BrowserKit/Tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
0