Skip to content

Commit

Permalink
Add Gate::after test
Browse files Browse the repository at this point in the history
  • Loading branch information
drbyte committed Oct 24, 2023
1 parent 9073f54 commit 9fec40a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/GateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ public function it_allows_other_gate_before_callbacks_to_run_if_a_user_does_not_
$this->assertFalse($this->testUser->can('edit-articles'));

app(Gate::class)->before(function () {
// this Gate-before intercept overrides everything to true ... like a typical Super-Admin might use
return true;
});

$this->assertTrue($this->testUser->can('edit-articles'));
}

/** @test */
public function it_allows_gate_after_callback_to_grant_denied_privileges()
{
$this->assertFalse($this->testUser->can('edit-articles'));

app(Gate::class)->after(function ($user, $ability, $result) {
return true;
});

Expand Down

0 comments on commit 9fec40a

Please sign in to comment.