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.

29 lines
722 B

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