NotFoundHttpException in phpUnit caused by redirect()->route()

Posted 1 month ago by finchy70

This simple test is failing.

/**
     * @test
     */
    public function it_can_create_a_job()
    {
        $client = create('App\Client');
        $job = make('App\Job', ['client_id' => $client->id]);
        $this->post('/jobs', $job->toArray())
            ->assertRedirect("/diary/1");

        $this->get('/diary/'.$job->id)
            ->assertSee($job->job_number)
            ->assertSee($client->name)
            ->assertSee($job->site);
    }

The error is Symfony\Component\HttpKernel\Exception\NotFoundHttpException:.

This seems to be caused by the redirect at the end of my controller code.

return redirect()->route('diary.show', $job->id);

Here is the route

Route::get('/diary/{id}', '[email protected]')->name('diary.show');

It all seems to work but this failing test is annoying me. Any one got any ideas what I am missing?

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