Be sure to have Session::start() at the beginning of your test. You can also place this in your setup function if you are using it several places.
May 11, 2019
21
Level 14
Session is missing expected key [errors]. Failed asserting that false is true.
Hi, I can't figure out how to get this to green. I get this error message when running this method
ERROR:
Session is missing expected key [errors].
Failed asserting that false is true.
METHOD:
/** @test */
public function a_reply_requires_a_body()
{
$this->withExceptionHandling()->signIn();
$thread = create('App\Thread');
$reply = make('App\Reply', ['body' => null]);
$this->post($thread->path().'/athugasemdir', $reply->toArray())
->assertSessionHasErrors('body');
}
Level 5
I had same problems with assertSessionHasErrors did not figured out exactly why. I believe you can check status because in controller you are sending 422:
$this->post($thread->path().'/athugasemdir', $reply->toArray())
->assertStatus(422);
4 likes
Please or to participate in this conversation.