Level 51
You need to create row in database with create()
$timesheet = factory(Timesheet::class)->create();
Hi,
I currently have this in my routes/web.php :
Route::middleware(['auth'])->group(function () {
Route::resource('timesheets', 'TimesheetController');
/* ... */
});
Auth::routes();
and have the following feature test :
function test_guests_cant_access_actions()
{
$timesheet = factory(Timesheet::class)->make();
$this->get(route('timesheets.index'))
->assertRedirect('/login');
$this->get(route('timesheets.create'))
->assertRedirect('/login');
$this->post(route('timesheets.store'))
->assertRedirect('/login');
$this->patch(route('timesheets.update', [$timesheet]))
->assertRedirect('/login'); // Line 29
$this->delete(route('timesheets.destroy', [$timesheet]))
->assertRedirect('/login');
}
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.
/home/james/Projects/workschedule/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:148
/home/james/Projects/workschedule/tests/Feature/Controllers/TimesheetControllerTest.php:29
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
You need to create row in database with create()
$timesheet = factory(Timesheet::class)->create();
Please or to participate in this conversation.