You are here

public function ClientTest::testHandlesRedirectsCorrectly in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/fabpot/goutte/Goutte/Tests/ClientTest.php \Goutte\Tests\ClientTest::testHandlesRedirectsCorrectly()

File

vendor/fabpot/goutte/Goutte/Tests/ClientTest.php, line 304

Class

ClientTest
Goutte Client Test.

Namespace

Goutte\Tests

Code

public function testHandlesRedirectsCorrectly() {
  $guzzle = $this
    ->getGuzzle([
    new GuzzleResponse(301, array(
      'Location' => 'http://www.example.com/',
    )),
    new GuzzleResponse(200, [], '<html><body><p>Test</p></body></html>'),
  ]);
  $client = new Client();
  $client
    ->setClient($guzzle);
  $crawler = $client
    ->request('GET', 'http://www.example.com/');
  $this
    ->assertEquals('Test', $crawler
    ->filter('p')
    ->text());

  // Ensure that two requests were sent
  $this
    ->assertEquals(2, count($this->history));
}