In browser, easyadmin is working fine. But when I run test case which asserts redirection logic to EasyAdmin's dashboard controller after login, it failed with the following error:
Uncaught PHP Exception LogicException: "Unable to add global "ea" as the runtime or the extensions
As it's pointed out in the following comment,
https://github.com/EasyCorp/EasyAdminBundle/issues/5591#issuecomment-1405962016
It seems to me that EasyAdmin twig extension is called after Twig extensions and runtime are initialized
easyadmin twig extension shouldn't be called before extensions and runtime are initialized and phpunit should pass
I found out the solution to my problem.
When multiple requests are executed in one test, since Symfony 5.4 the
Clientreboots the Kernel for each request. So to be able to run several request in the test, I should have added$this->client->enableReboot();in the test cases which execute several requests.Here is the link https://symfony.com/doc/current/testing.html#multiple-requests-in-one-test