Skip to content

Commit

Permalink
[5.7] Add Unit test for Auth/Access/Gate.php:define when InvalidArg…
Browse files Browse the repository at this point in the history
…umentException caused; (#25564)

- added unit test for `Auth/Access/Gate.php:define` when InvalidArgumentException caused, since we did not have a test for this case;
  • Loading branch information
TBlindaruk authored and taylorotwell committed Sep 11, 2018
1 parent 8086c86 commit d2dc1f3
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/Auth/AuthAccessGateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,30 @@ public function test_for_user_method_attaches_a_new_user_to_a_new_gate_instance(
$this->assertTrue($gate->forUser((object) ['id' => 2])->check('foo'));
}

/**
* @dataProvider notCallableDataProvider
* @expectedException \InvalidArgumentException
*/
public function test_define_second_parametter_should_be_string_or_callable($callback)
{
$gate = $this->getBasicGate();

$gate->define('foo', $callback);
}

/**
* @return array
*/
public function notCallableDataProvider()
{
return [
[1],
[new \stdClass()],
[[]],
[1.1],
];
}

/**
* @expectedException \Illuminate\Auth\Access\AuthorizationException
* @expectedExceptionMessage You are not an admin.
Expand Down

0 comments on commit d2dc1f3

Please sign in to comment.