Total Complexity | 5 |
Total Lines | 58 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
10 | class FieldUnitTest extends TestCase |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * Testing constructor |
||
15 | */ |
||
16 | public function testNoNameException(): void |
||
17 | { |
||
18 | $this->expectException(\Exception::class); |
||
19 | new \Mezon\Gui\Field([], ''); |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * Testing setters |
||
24 | */ |
||
25 | public function testNameSetter(): void |
||
26 | { |
||
27 | // test body |
||
28 | $field = new \Mezon\Gui\Field(json_decode(file_get_contents(__DIR__ . '/conf/name-setter.json'), true), ''); |
||
29 | |||
30 | // assertions |
||
31 | $this->assertStringContainsString('prefixfield-name000', $field->html(), 'Invalid field "name" value'); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Testing setters |
||
36 | */ |
||
37 | public function testRequiredSetter(): void |
||
38 | { |
||
39 | // test body |
||
40 | $field = new \Mezon\Gui\Field(json_decode(file_get_contents(__DIR__ . '/conf/required-setter.json'), true), ''); |
||
41 | |||
42 | // assertions |
||
43 | $this->assertStringContainsString('prefixfield-name1111select2', $field->html(), 'Invalid field "name" value'); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Testing exception if type not set |
||
48 | */ |
||
49 | public function testTypeException(): void |
||
50 | { |
||
51 | // setup and assertions |
||
52 | $this->expectExceptionCode(- 2); |
||
53 | |||
54 | // test body |
||
55 | new \Mezon\Gui\Field([], ''); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * Testing setters |
||
60 | */ |
||
61 | public function testHasLabelSetter(): void |
||
68 | } |
||
69 | } |
||
70 |