{!! $sol !!} namespace Tests\Feature\{{class_basename($model)}}; use App\Models\{{class_basename($model)}}; use Tests\Bootstrap; class {{class_basename($model)}}DeleteTest extends Bootstrap { public function test_{{lcfirst(class_basename($model))}}_delete_success() { $this->modelWithPolicy('{{$model->getTable()}}', ['permission:{{$model->getTable()}}.delete']) ->loginAs(['{{$model->getTable()}}.delete']) ->deleteJson(route("api.{{$model->getTable()}}.delete", ${{lcfirst(class_basename($model))}} = $this->one({{class_basename($model)}}::class))) ->assertOk(); $this->loginAsAdmin() ->getJson(route("api.{{$model->getTable()}}.show", ${{lcfirst(class_basename($model))}})) ->assertNotFound(); } public function test_{{lcfirst(class_basename($model))}}_restore_success() { $this->modelWithPolicy('{{$model->getTable()}}', ['permission:{{$model->getTable()}}.restore']) ->loginAsUser(['{{$model->getTable()}}.restore']) ->deleteJson(route("api.{{$model->getTable()}}.delete", ${{lcfirst(class_basename($model))}} = $this->trashed({{class_basename($model)}}::class))) ->assertOk(); $this->loginAsAdmin() ->getJson(route("api.{{$model->getTable()}}.show", ${{lcfirst(class_basename($model))}})) ->assertOk(); } public function test_{{lcfirst(class_basename($model))}}_delete_forbidden() { $this->modelWithPolicy('{{$model->getTable()}}', ['permission:{{$model->getTable()}}.delete']) ->loginAs(['wrong.permission']) ->deleteJson(route("api.{{$model->getTable()}}.delete", ${{lcfirst(class_basename($model))}} = $this->one({{class_basename($model)}}::class))) ->assertForbidden(); } public function test_{{lcfirst(class_basename($model))}}_restore_forbidden() { $this->modelWithPolicy('{{$model->getTable()}}', ['permission:{{$model->getTable()}}.restore']) ->loginAs(['wrong.permission']) ->deleteJson(route("api.{{$model->getTable()}}.delete", ${{lcfirst(class_basename($model))}} = $this->trashed({{class_basename($model)}}::class))) ->assertForbidden(); } public function test_{{lcfirst(class_basename($model))}}_delete_notFound() { $this->loginAsAdmin() ->deleteJson(route("api.{{$model->getTable()}}.delete", 0)) ->assertNotFound(); } }