|
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
|
|
|
|