Passed
Push — master ( 23152a...a65783 )
by Povilas
02:36
created

ListFieldExceptionTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 18
dl 0
loc 41
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testInvalidPath() 0 5 1
A testInvalidFieldConfiguration() 0 5 1
A testFieldNotExists() 0 5 1
A testGetFieldId() 0 4 1
A testInvalidPropertiesOption() 0 5 1
A testInvalidType() 0 5 1
1
<?php
2
3
namespace Povs\ListerBundle\Exception;
4
5
use PHPUnit\Framework\TestCase;
6
7
/**
8
 * @author Povilas Margaiatis <[email protected]>
9
 */
10
class ListFieldExceptionTest extends TestCase
11
{
12
    public function testInvalidFieldConfiguration(): void
13
    {
14
        $expected = 'Invalid field "test" configuration. config_error';
15
        $actual = ListFieldException::invalidFieldConfiguration('test', 'config_error')->getMessage();
16
        $this->assertEquals($expected, $actual);
17
    }
18
19
    public function testFieldNotExists(): void
20
    {
21
        $expected = 'Field "id" do not exists';
22
        $actual = ListFieldException::fieldNotExists('id')->getMessage();
23
        $this->assertEquals($expected, $actual);
24
    }
25
26
    public function testInvalidPropertiesOption(): void
27
    {
28
        $expected = '"id" - properties can only be set for a single path';
29
        $actual = ListFieldException::invalidPropertiesOption('id')->getMessage();
30
        $this->assertEquals($expected, $actual);
31
    }
32
33
    public function testInvalidPath(): void
34
    {
35
        $expected = 'Could not find join for path "path"';
36
        $actual = ListFieldException::invalidPath('path')->getMessage();
37
        $this->assertEquals($expected, $actual);
38
    }
39
40
    public function testInvalidType(): void
41
    {
42
        $expected = 'Type "foo" does not exist or does not implement bar';
43
        $actual = ListFieldException::invalidType('id', 'foo', 'bar')->getMessage();
44
        $this->assertEquals($expected, $actual);
45
    }
46
47
    public function testGetFieldId(): void
48
    {
49
        $exception = new ListFieldException('id');
50
        $this->assertEquals('id', $exception->getFieldId());
51
    }
52
}
53