followMetaRefresh($followMetaRefresh); $client->setNextResponse(new Response($content)); $client->request('GET', 'http://www.example.com/foo/foobar'); $this->assertEquals($expectedEndingUrl, $client->getRequest()->getUri()); } public function getTestsForMetaRefresh() { return [ ['', 'http://www.example.com/redirected'], ['', 'http://www.example.com/redirected'], ['', 'http://www.example.com/redirected'], ['', 'http://www.example.com/redirected'], ['', 'http://www.example.com/redirected'], ['', 'http://www.example.com/redirected'], ['', 'http://www.example.com/redirected'], ['', 'http://www.example.com/redirected'], // Non-zero timeout should not result in a redirect. ['', 'http://www.example.com/foo/foobar'], ['', 'http://www.example.com/foo/foobar'], // HTML 5 allows the meta tag to be placed in head or body. ['', 'http://www.example.com/redirected'], // Valid meta refresh should not be followed if disabled. ['', 'http://www.example.com/foo/foobar', FALSE], 'drupal-1' => ['', 'http://www.example.com/update.php/start?id=2&op=do_nojs'], 'drupal-2' => ['', 'http://www.example.com/update.php/start?id=2&op=do_nojs'], ]; } /** * @covers ::request */ public function testBackForwardMetaRefresh() { $client = new TestClient(); $client->followMetaRefresh(); // First request. $client->request('GET', 'http://www.example.com/first-page'); $content = ''; $client->setNextResponse(new Response($content, 200)); $client->request('GET', 'http://www.example.com/refresh-from-here'); $this->assertEquals('http://www.example.com/refreshed', $client->getRequest()->getUri()); $client->back(); $this->assertEquals('http://www.example.com/first-page', $client->getRequest()->getUri()); $client->forward(); $this->assertEquals('http://www.example.com/refreshed', $client->getRequest()->getUri()); } } /** * Special client that can return a given response on the first doRequest(). */ class TestClient extends DrupalMinkClient { protected $nextResponse = NULL; public function setNextResponse(Response $response) { $this->nextResponse = $response; } protected function doRequest($request) { if (NULL === $this->nextResponse) { return new Response(); } $response = $this->nextResponse; $this->nextResponse = NULL; return $response; } }