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.0 KiB

  1. <?php
  2. namespace Tests\Feature\Collection;
  3. use App\Models\Collection;
  4. use Tests\Bootstrap;
  5. use App\Models\User;
  6. class CollectionShowTest extends Bootstrap
  7. {
  8. public function test_collection_show_success()
  9. {
  10. $this->modelWithPolicy('collections', ['permission:collections.show'])
  11. ->loginAs(['collections.show'])
  12. ->getJson(route("api.collections.show", $collection = $this->one(Collection::class)))
  13. ->assertOk();
  14. }
  15. public function test_collection_show_not_found()
  16. {
  17. $this->modelWithPolicy('collections', ['permission:collections.show'])
  18. ->loginAs(['collections.show'])
  19. ->getJson(route("api.collections.show", 0))
  20. ->assertNotFound();
  21. }
  22. public function test_collection_show_forbidden()
  23. {
  24. $this->modelWithPolicy('collections', ['permission:collections.show'])
  25. ->loginAs(['wrong.permission'])
  26. ->getJson(route("api.collections.show", $collection = $this->one(Collection::class)), [])
  27. ->assertForbidden();
  28. }
  29. }