Do you really need all 3 assertions? Is the session key the main thing you are trying to test or would it be enough to check the HTTP status code (200 OK as opposed to some error code) + assertSee? Is there a situation where the session key is NOT set but the rest of the action would be successful and return 200?
Jun 28, 2019
5
Level 11
Testing flash messages and redirects
Hello,
I wrote the following test but it's not working :
$this->followingRedirects()
->post('/contact-me', $attributes)
->assertSessionHas('contact.success')
->assertStatus(200)
->assertSee('confirm');
It returns :
Session is missing expected key [contact.success].
Failed asserting that false is true.
Obviously it's because of $this->followingRedirects().
Does anyone have a solution?
Thanks in advance,
Alex
Please or to participate in this conversation.