Test Failed
Branch master (5e8424)
by Randy
02:43
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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testValidEnforce() 0 4 1
A testInvalidEnforce() 0 7 1
A testInvalidEnforceWithException() 0 7 1
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
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
{
9
}
10
11
class EnforcementTest extends TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
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
}