Can someone explain to me why when I use the assertResponseRedirects method with PHPUnit by passing the URI as a parameter:
class UserControllerTest extends WebTestCase
{
public function testUnauthenticatedIsRedirected(): void
{
$this->client->request('GET', '/account');
static::assertResponseRedirects('/login');
}
}
I have this error:
Failed asserting that Symfony\Component\HttpFoundation\RedirectResponse Object &0000000044abc158000000000cda95f8 (
'targetUrl' => 'http://localhost/login'
...
But if I put the absolute URL, the test works:
public function testUnauthenticatedIsRedirected(): void
{
$this->client->request('GET', '/account');
static::assertResponseRedirects('http://localhost/login');
}
Everyone puts the URI and it works, but not me... I'm on Symfony 5.2.1
Thank you in advance