i have created a test for my create method to test out my controller but cant seem to see the issue at hand, can any one shed some light please , this is my update controller test
public function test_if_user_can_update_a_supplier()
{
//Make fake data, don't persist to database.
$supplier = Supplier::factory()->make()->setAppends([])->makeHidden(['created_at', 'updated_at']);
//Create an Admin User and assign the Administrator role to this new user
$adminUser = factory(AdminUser::class)->create();
$adminUser->roles()->sync(Role::where('name', 'Administrator')->first());
//Make the request as the new authenticated Administrator user with the admin guard.
$this->actingAs($adminUser, config('admin-auth.defaults.guard'))
->json(
'POST',
route('admin/suppliers/update'),
$supplier->toArray()
)
->assertStatus(302)
->assertRedirectToRoute('admin/suppliers/index');
$this->assertDatabaseHas(
'suppliers',
$supplier->toArray()
);
}
i get this error when running the test Missing required parameter for [Route: admin/suppliers/update] [URI: admin/suppliers/{supplier}] [Missing parameter: supplier].
But when i add the @supplier->id to
route('admin/suppliers/update' , $supplier-id ),
$supplier->toArray()
)
i still get the same error
This is the delete test that returns the same error
public function test_if_a_user_can_delete_a_supplier()
{
//Make fake data, don't persist to database.
$supplier = Supplier::factory()->make()->setAppends([])->makeHidden(['created_at', 'updated_at']);
//Create an Admin User and assign the Administrator role to this new user
$adminUser = factory(AdminUser::class)->create();
$adminUser->roles()->sync(Role::where('name', 'Administrator')->first());
$this->actingAs($adminUser, config('admin-auth.defaults.guard'))
->json(
'DELETE',
route('admin/suppliers/destroy'),
$supplier->toArray()
)
->assertStatus(302)
->assertRedirectToRoute('admin/suppliers/index');
$this->assertDatabaseMissing(
'suppliers',
$supplier->toArray()
);
}