How to get the current URL after a redirect in a Symfony2 WebTestCase?

symfony, testing

Solution

You can get the current URL with `$client->getResponse()->headers->get('location')`, and assert it ends with /login using `assertRegExp()`.

$this->assertRegExp('/\/login$/', $client->getResponse()->headers->get('location'));

Problem

Using the Symfony2 WebTestCase, I have the following test : ``` $client->request('GET', '/'); $this->assertTrue($client->getResponse() instanceof RedirectResponse); $crawler = $client->followRedirect(); ``` I would like to test the new url, after the redirection ends with `/login` but I have found no way to access the new URL.

Original source