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