我收到如下错误
Found unexpected records in database table [customers] that matched attributes [{"id":89}].
Failed asserting that 1 matches expected 0.
CustomerTest.php:
public function testDestroyCustomer()
{
// $this->assertTrue(true);
$post = factory(Customer::class,1)->create();
$this->delete(route('customer.destroy', $post->id));
$this->assertResponseStatus(500);
$this->dontSeeInDatabase('customers', ['id' => $post->id]);
}
routes.php文件
Route::resource('customer', 'CustomerController', [
'names' => [
'index' => 'customer'
]
]);
CustomerController中的销毁函数:
public function destroy($id)
{
$delete = Customer::where('id',$id)->delete();
}
如何解决错误?任何建议请。
答案 0 :(得分:0)
我认为您的删除路由应该是,
变化:
route('customer.destroy', $post->id);
至
route('customer.destroy', ['id' => $post->id]);