Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Antonella's avatar

TDD: LogicException: App\Models\Project::path must return a relationship instance.

I'm at this lesson https://laracasts.com/series/build-a-laravel-app-with-tdd/episodes/14 minute 18:16

when i launch this test i get a different error than the course one

   public function test_a_user_can_create_a_project()
    {

        $this->withoutExceptionHandling();

        $this->singIn();

        $this->get('/projects/create')->assertStatus(200);

        $attributes = [
            'title' => $this->faker->sentence,
            'description' => $this->faker->paragraph,
        ];

        $response = $this->post('/projects', $attributes);

        $project = Project::where($attributes)->first();

        $response->assertRedirect($project->path);

        $this->assertDatabaseHas('projects',$attributes);

        $this->get('/projects')->assertSee($attributes['title']);
    }

gives me following errors:

  1. Tests\Feature\ManageProjectsTest::test_a_user_can_create_a_project LogicException: App\Models\Project::path must return a relationship instance.
0 likes
3 replies
Tray2's avatar
Tray2
Best Answer
Level 73

This row

$response->assertRedirect($project->path);

is the problem

It should probably have () on the end.

 $response->assertRedirect($project->path());
1 like
Tray2's avatar

Have you followed the tutorial properly?

When you redirect in your controller you need to add the id of the project at the end of the route.

Please or to participate in this conversation.