Total Complexity | 3 |
Total Lines | 28 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | trait ArrayizableElementTestTrait |
||
15 | { |
||
16 | /** @var class-string */ |
||
17 | protected static string $testedClass; |
||
18 | |||
19 | /** @var array */ |
||
20 | protected static array $arrayRepresentation; |
||
21 | |||
22 | |||
23 | /** |
||
24 | * Test arrayization / de-arrayization |
||
25 | */ |
||
26 | public function testArrayization(): void |
||
27 | { |
||
28 | if (!class_exists(self::$testedClass)) { |
||
29 | $this->markTestSkipped( |
||
30 | 'Unable to run ' . self::class . '::testArrayization(). Please set ' . self::class |
||
31 | . ':$element to a class-string representing the XML-class being tested', |
||
32 | ); |
||
33 | } elseif (self::$arrayRepresentation === null) { |
||
34 | $this->markTestSkipped( |
||
35 | 'Unable to run ' . self::class . '::testArrayization(). Please set ' . self::class |
||
36 | . ':$arrayRepresentation to an array representing the XML-class being tested', |
||
37 | ); |
||
38 | } else { |
||
39 | $this->assertEquals( |
||
40 | self::$arrayRepresentation, |
||
41 | self::$testedClass::fromArray(self::$arrayRepresentation)->toArray(), |
||
42 | ); |
||
46 |