Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[BrowserKit] Added isFollowingRedirects and getMaxRedirects methods
  • Loading branch information
Naktibalda authored and fabpot committed Sep 26, 2015
1 parent 4fcf136 commit b475607
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Symfony/Component/BrowserKit/Client.php
Expand Up @@ -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.
*
Expand All @@ -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.
*
Expand Down
16 changes: 16 additions & 0 deletions src/Symfony/Component/BrowserKit/Tests/ClientTest.php
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 comments on commit b475607

Please sign in to comment.