liip / LiipFunctionalTestBundle

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

[3.x-dev] Symfony 5.0 Form must be an instance of Client instead of KernelBrowser #558

Closed Voetloos closed 4 years ago

Voetloos commented 4 years ago

I upgrade my project to Symfony 5.0. Since this bundle is not yet updated I used the dev version. However, when running tests I get the following error:

TypeError: Argument 1 passed to App\Tests\PagesTestCase::form() must be an instance of Symfony\Bundle\FrameworkBundle\Client, instance of Symfony\Bundle\FrameworkBundle\KernelBrowser given

Argument 1 in this form is $userClient, which is created with createClient. In Symfony 5, Symfony\Bundle\FrameworkBundle\Client is removed.

I looked into this and found in QueryCountClient.php the following:

if (!class_exists(Client::class)) {
    class_alias(KernelBrowser::class, Client::class);
}

I suspect this is either not working or missing in some other place.

Voetloos commented 4 years ago

I still had Client somewhere in my code, so it expected a client.

alexislefebvre commented 4 years ago

Feel free to add the required changes in the bundle documentation, it could be a new section about Symfony 5, it could fit in the https://github.com/liip/LiipFunctionalTestBundle/blob/master/CHANGELOG.md