rshepard21
2 years ago
617
8
Testing

ParticipateInThreadsTest Error

Posted 2 years ago by rshepard21

I am following along on the Laravel Forum With TDD series. I have ran upon an issue where i get an error with the a_reply_requires_a_body test:

function a_reply_requires_a_body()
{
        $this->withExceptionHandling()->signIn();

        $thread = create('App\Thread');

        $reply = make('App\Reply', ['body' => null]);

        $this->post($thread->path() . '/replies', $reply->toArray())
            ->assertSessionHasErrors('body');
}

It tells me after running phpunit:

1) Tests\Feature\ParticipateInForumTest::a_reply_requires_a_body
Session is missing expected key [errors].
Failed asserting that false is true.

And this is my validation on the store method:

$this->validate(request(), [
    'body' => ['required', new SpamFree],
]);

Please sign in or create an account to participate in this conversation.