liip / LiipFunctionalTestBundle

Some helper classes for writing functional tests in Symfony
http://liip.ch
MIT License
639 stars 182 forks source link

Create WebTestCase::loginClient to allow working with a single kernel #567

Closed ndench closed 4 years ago

ndench commented 4 years ago

Booting a kernel before calling Symfony WebTestCase::createClient() is deprecated in Symfony 4.4 (symfony/symfony#32056). This exposed an issue with LiipTestFixturesBundle which was causing multiple kernels to be booted during a test. After fixing this in liip/LiipTestFixturesBundle#62 it was brought to my attention that Liip WebTestCase::loginAs is now broken since we require the client to be created before loading fixtures.

As a result, I think deprecating the loginAs method and adding a loginClient method is the best path forward. Note that in Symfony 5.1 we have $client->loginUser() which is very similar.

I've been using a similar helper function in my projects for a couple of years now, and after suggesting it as an option on https://github.com/liip/LiipTestFixturesBundle/pull/62#issuecomment-622191412 others have reported that it works for them as well.

alexislefebvre commented 4 years ago

Thanks! You will find it in last version: https://github.com/liip/LiipFunctionalTestBundle/releases/tag/4.2.0