Somewhere between Symfony 5.0.5 and 5.0.8 the exception
LogicException: Booting the kernel before calling "Symfony\Bundle\FrameworkBundle\Test\WebTestCase::createClient()" is not supported, the kernel should only be booted once.
is generated. In 5.05 the test shown below passes. After updating to 5.08 the test fails. While the exception appears elsewhere in SO the answer does solve the present issue. What is missing in order to allow 5.08 to pass this and similar tests?
namespace App\Tests\Controller;
use Liip\TestFixturesBundle\Test\FixturesTrait;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class AdminControllerTest extends WebTestCase
{
use FixturesTrait;
public function setup(): void
{
$this->fixtures = $this->loadFixtures([
'App\DataFixtures\Test\OptionsFixture',
'App\DataFixtures\Test\NonprofitFixture',
'App\DataFixtures\Test\UserFixture',
])
->getReferenceRepository();
$this->client = static::createClient(); // <-- this line causes failure
$this->client->followRedirects();
$this->client->request('GET', '/login');
$this->client->submitForm('Sign in', [
'email' => '[email protected]',
'password' => '123Abc',
]);
}
public function testLogin()
{
$this->client->request('GET', '/admin/dashboard');
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
}
...
}