zerodps's avatar

Test Troubleshooting / WAMP Laravel 5.8.26 W10

Hi all,

I am trying to get this test running but phpunit is giving me a error message which leaves me more clueless than before...


Tests\Feature\ManageProjectsTest::a_user_can_create_a_project
Error: Class 'Tests\Feature\Project' not found


the test:


public function a_user_can_create_a_project()
    {
        $this->withoutExceptionHandling();
        $this->signIn();
        $this->get('/projects/create')->assertStatus(200);

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

        $response = $this->post('/projects', $attributes);
        $response->assertRedirect(Project::where($attributes)->first()->path());

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

I am certain that this line is the issue. However I cant explain the reason or any fix for it


     $response->assertRedirect(Project::where($attributes)->first()->path());


Thanks in advance !

0 likes
2 replies
Jaytee's avatar
Jaytee
Best Answer
Level 39

You haven't imported the Project model at the top of the file, thus it's trying to look for it in the tests folder instead.

1 like
zerodps's avatar

@JAYTEE - Oh .. wow thanks for the quick answer and fix.

I really appreciate it!

1 like

Please or to participate in this conversation.