| 1 | <?php |
||
| 11 | class EnforcementTest extends TestCase |
||
| 12 | { |
||
| 13 | public function testValidEnforce() |
||
| 14 | { |
||
| 15 | enforce(true)->orThrow('That is not true?!'); |
||
| 16 | } |
||
| 17 | |||
| 18 | public function testInvalidEnforce() |
||
| 19 | { |
||
| 20 | $this->expectException(EnsuranceException::class); |
||
| 21 | $this->expectExceptionMessage('That is false'); |
||
| 22 | |||
| 23 | enforce(false)->orThrow('That is false'); |
||
| 24 | } |
||
| 25 | |||
| 26 | public function testInvalidEnforceWithException() |
||
| 27 | { |
||
| 28 | $this->expectException(FooException::class); |
||
| 29 | $this->expectExceptionMessage('That is false'); |
||
| 30 | |||
| 31 | enforce(false)->orThrow(new FooException('That is false')); |
||
| 32 | } |
||
| 33 | } |