thunderer /
Platenum
| 1 | <?php |
||
| 2 | declare(strict_types=1); |
||
| 3 | namespace Thunder\Platenum\Tests; |
||
| 4 | |||
| 5 | use Thunder\Platenum\Exception\PlatenumException; |
||
| 6 | use Thunder\Platenum\Enum\StaticEnumTrait; |
||
| 7 | use Thunder\Platenum\Tests\Fake\FakeEnum; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @author Tomasz Kowalczyk <[email protected]> |
||
| 11 | */ |
||
| 12 | final class StaticEnumTest extends AbstractTestCase |
||
| 13 | { |
||
| 14 | public function testMembers(): void |
||
| 15 | { |
||
| 16 | $members = ['FIRST' => 1, 'SECOND' => 2]; |
||
| 17 | $trait = $this->makeStaticTraitEnum($members); |
||
| 18 | $extends = $this->makeStaticExtendsEnum($members); |
||
| 19 | |||
| 20 | $this->assertSame($members, $trait::getMembersAndValues()); |
||
| 21 | $this->assertSame($members, $extends::getMembersAndValues()); |
||
| 22 | } |
||
| 23 | |||
| 24 | public function testExceptionMissingProperty(): void |
||
| 25 | { |
||
| 26 | /** @var FakeEnum $enum */ |
||
| 27 | $enum = $this->computeUniqueClassName('X'); |
||
| 28 | eval('class '.$enum.' { use '.StaticEnumTrait::class.'; }'); |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 29 | |||
| 30 | $this->expectException(PlatenumException::class); |
||
| 31 | $this->expectExceptionMessage('Enum '.$enum.' requires static property $mapping with members definitions.'); |
||
| 32 | $enum::FIRST(); |
||
| 33 | } |
||
| 34 | } |
||
| 35 |