Completed
Branch master (60648a)
by Randy
03:56
created

EnforcementTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 3
1
<?php
2
3
use Dgame\Ensurance\Exception\EnsuranceException;
4
use PHPUnit\Framework\TestCase;
5
use function Dgame\Ensurance\enforce;
6
7
class FooException extends Exception
8
{
9
}
10
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
}