Danieloplata
10 months ago

405 Method Not Allowed

Posted 10 months ago by Danieloplata

Hi, I'm trying to get a test working for my destroy method and it's failing with a 405 response.

My test:

...

public function setUp() 
{
    parent::setup();
    $this->be($user = factory('App\User')->create());
    $this->project = factory('App\Project')->create();
}

...

/** @test */
public function an_authenticated_user_can_delete_a_project()
{
    $response = $this->delete($this->project->path());
    $response->assertStatus(200);
    $response->assertRedirect(route('projectsOverview'));
}

My route:

Route::prefix('projects')->middleware('auth')->group(function () {
    ...
    Route::delete('/{project}', '[email protected]')->name('destroyProject');
});

My destroy method:

public function destroy(Project $project) 
{
    $project->delete();

    return redirect()
        ->route('projectsOverview')
        ->with('message', 'Project deleted');
}

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