9 months ago

Laravel 5.7 : Unable to test Patch/Put/Delete routes

Posted 9 months ago by Jamesst20


I currently have this in my routes/web.php :

Route::middleware(['auth'])->group(function () {
    Route::resource('timesheets', 'TimesheetController');
    /* ... */

and have the following feature test :

    function test_guests_cant_access_actions()
        $timesheet = factory(Timesheet::class)->make();

        $this->patch(route('timesheets.update', [$timesheet]))
            ->assertRedirect('/login'); // Line 29
        $this->delete(route('timesheets.destroy', [$timesheet]))

Sadly, I am getting this error

1) Tests\Feature\Controllers\TimesheetControllerTest::test_guests_cant_access_actions
Response status code [405] is not a redirect status code.
Failed asserting that false is true.


Which means the route is not responding to my request method.

I am unable to explain it. Would anyone be able to help me understand what i'm doing wrong ?

Thank you

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