Symfony 5.0.5 和 5.0.8 之间的某个地方例外
LogicException:不支持在调用“Symfony\Bundle\FrameworkBundle\Test\WebTestCase::createClient()”之前启动内核,内核只能启动一次。
生成。在 5.05 中,下面显示的测试通过了。更新到 5.08 后测试失败。虽然异常出现在 SO 的其他地方,但答案确实解决了当前的问题。为了让 5.08 通过这个和类似的测试,缺少什么?
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' => 'admin@bogus.info',
'password' => '123Abc',
]);
}
public function testLogin()
{
$this->client->request('GET', '/admin/dashboard');
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
}
...
}
墨色风雨