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.

25 lines
681 B

2 years ago
  1. <?php
  2. namespace Tests\iLaravel\Policies;
  3. use App\Models\ILaravel;
  4. use Tests\Bootstrap;
  5. class PermissionPolicyTest extends Bootstrap
  6. {
  7. function test_permission_policy_successful()
  8. {
  9. $this->modelWithPolicy('ilaravels', ['permission:show'])
  10. ->loginAs(['show'])
  11. ->getJson(route('api.ilaravels.show', $this->one(ILaravel::class)))
  12. ->assertOk();
  13. }
  14. function test_permission_policy_fail()
  15. {
  16. $this->modelWithPolicy('ilaravels', ['permission:show'])
  17. ->loginAs(['wrong.permission'])
  18. ->getJson(route('api.ilaravels.show', $this->one(ILaravel::class)))
  19. ->assertForbidden();
  20. }
  21. }