Skip to content

Commit

Permalink
fix: use try catch to invalid filter type
Browse files Browse the repository at this point in the history
  • Loading branch information
basakest committed Mar 25, 2021
1 parent a4547b1 commit 8b3cd3e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/DatabaseAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,14 @@ public function testLoadFilteredPolicy()
$this->assertEquals([], Enforcer::getPolicy());

// invalid filter type
$this->expectException(InvalidFilterTypeException::class);
$this->expectExceptionMessage('invalid filter type');
$filter = ['alice', 'data1', 'read'];
Enforcer::loadFilteredPolicy($filter);
try {
$filter = ['alice', 'data1', 'read'];
Enforcer::loadFilteredPolicy($filter);
$e = InvalidFilterTypeException::class;
$this->fail("Expected exception $e not thrown");
} catch (InvalidFilterTypeException $e) {
$this->assertEquals("invalid filter type", $e->getMessage());
}

// string
$filter = "v0 = bob";
Expand Down

0 comments on commit 8b3cd3e

Please sign in to comment.