[BrowserKit] Added isFollowingRedirects and getMaxRedirects methods

This commit is contained in:
Gintautas Miselis 2015-09-04 23:25:23 +01:00 committed by Fabien Potencier
parent 4fcf136079
commit b47560773e
2 changed files with 36 additions and 0 deletions

View File

@ -74,6 +74,16 @@ abstract class Client
$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 @@ abstract class Client
$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.
*

View File

@ -492,6 +492,22 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$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();