Answer the question
In order to leave comments, you need to log in
How to test redirects?
Something like this only for Symphony. https://medium.com/@splatEric/laravel-testing-tidb...
We have 2 firewalls, 1 for the admin panel and another for the API. In the second case, everything is simple, the redirect does the client-side, because it does not have login data, so you can just test the response, there will be something like ACCESS_DENIED response.
But what about the translation to the login page? How can you test a redirect to the login page if the user tried to go to a secure route?
Answer the question
In order to leave comments, you need to log in
You can write a simple functional test: https://symfony.com/doc/current/testing.html#your-...
public function testRedirectsNotAuthenticatedUsersToLoginPage()
{
$client = static::createClient();
$client->request('GET', '/account/secrets');
$this->assertTrue($client->getResponse()->isRedirect('/login'));
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question