您如何测试 FlashBag 消息?
试过这个:
public function testInvalidLogin()
{
    $session = $this->client->getContainer()->get('session');
    $crawler = $this->client->request('GET', '/login');
    $this->assertTrue($this->client->getResponse()->isSuccessful());
    $form = $crawler->filter('form');
    $this->assertGreaterThan(0, $form->count());
    $form = $form->form();
    $this->assertNotEmpty($form);
    $form['_username'] = 'username';
    $form['_password'] = 'password';
    $this->client->submit($form);
    $this->assertTrue($this->client->getResponse()->isRedirect('http://localhost/login'));
    $this->client->followRedirect();
    $session = $this->client->getContainer()->get('session');
    var_dump($session->getBag('flashes')->all()); // this print an empty array
}
登录控制器设置了一条闪存消息“凭据错误”,但在测试期间我无法看到它。