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
This commit is contained in:
commit
4a98f287bd
@ -74,6 +74,16 @@ abstract class Client
|
|||||||
$this->followRedirects = (bool) $followRedirect;
|
$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.
|
* Sets the maximum number of requests that crawler can follow.
|
||||||
*
|
*
|
||||||
@ -85,6 +95,16 @@ abstract class Client
|
|||||||
$this->followRedirects = -1 != $this->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.
|
* Sets the insulated flag.
|
||||||
*
|
*
|
||||||
|
@ -492,6 +492,22 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals($headers, $client->getRequest()->getServer());
|
$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()
|
public function testBack()
|
||||||
{
|
{
|
||||||
$client = new TestClient();
|
$client = new TestClient();
|
||||||
|
Reference in New Issue
Block a user