You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.4 KiB

2 years ago
  1. {!! $sol !!}
  2. namespace Tests\Feature\{{class_basename($model)}};
  3. use App\Models\{{class_basename($model)}};
  4. use Tests\Bootstrap;
  5. use App\Models\User;
  6. class {{class_basename($model)}}ShowTest extends Bootstrap
  7. {
  8. public function test_{{lcfirst(class_basename($model))}}_show_success()
  9. {
  10. $this->modelWithPolicy('{{$model->getTable()}}', ['permission:{{$model->getTable()}}.show'])
  11. ->loginAs(['{{$model->getTable()}}.show'])
  12. ->getJson(route("api.{{$model->getTable()}}.show", ${{lcfirst(class_basename($model))}} = $this->one({{class_basename($model)}}::class)))
  13. ->assertOk();
  14. }
  15. public function test_{{lcfirst(class_basename($model))}}_show_not_found()
  16. {
  17. $this->modelWithPolicy('{{$model->getTable()}}', ['permission:{{$model->getTable()}}.show'])
  18. ->loginAs(['{{$model->getTable()}}.show'])
  19. ->getJson(route("api.{{$model->getTable()}}.show", 0))
  20. ->assertNotFound();
  21. }
  22. public function test_{{lcfirst(class_basename($model))}}_show_forbidden()
  23. {
  24. $this->modelWithPolicy('{{$model->getTable()}}', ['permission:{{$model->getTable()}}.show'])
  25. ->loginAs(['wrong.permission'])
  26. ->getJson(route("api.{{$model->getTable()}}.show", ${{lcfirst(class_basename($model))}} = $this->one({{class_basename($model)}}::class)), [])
  27. ->assertForbidden();
  28. }
  29. }