|
20 | 20 |
|
21 | 21 | declare(strict_types=1); |
22 | 22 |
|
23 | | -namespace PackageFactory\ComponentEngine\Test\Unit\TypeSystem\Type\EnumStaticType; |
| 23 | +namespace PackageFactory\ComponentEngine\Test\Unit\TypeSystem\Type\EnumType; |
24 | 24 |
|
25 | 25 | use PackageFactory\ComponentEngine\Module\ModuleId; |
26 | 26 | use PackageFactory\ComponentEngine\Parser\Ast\EnumDeclarationNode; |
| 27 | +use PackageFactory\ComponentEngine\TypeSystem\Type\EnumType\EnumInstanceType; |
27 | 28 | use PackageFactory\ComponentEngine\TypeSystem\Type\EnumType\EnumStaticType; |
28 | 29 | use PHPUnit\Framework\TestCase; |
29 | 30 |
|
@@ -62,4 +63,62 @@ public function providesNameOfTheEnum(): void |
62 | 63 |
|
63 | 64 | $this->assertEquals('SomeEnum', $enumStaticType->enumName); |
64 | 65 | } |
| 66 | + |
| 67 | + /** |
| 68 | + * @test |
| 69 | + */ |
| 70 | + public function providesMemberNames(): void |
| 71 | + { |
| 72 | + $enumStaticType = EnumStaticType::fromModuleIdAndDeclaration( |
| 73 | + ModuleId::fromString("module-a"), |
| 74 | + EnumDeclarationNode::fromString( |
| 75 | + 'enum SomeEnum { A B C }' |
| 76 | + ) |
| 77 | + ); |
| 78 | + |
| 79 | + $this->assertSame(["A", "B", "C"], $enumStaticType->getMemberNames()); |
| 80 | + } |
| 81 | + |
| 82 | + /** |
| 83 | + * @test |
| 84 | + * @return void |
| 85 | + */ |
| 86 | + public function canBeTransformedIntoInstanceType(): void |
| 87 | + { |
| 88 | + $enumDeclarationNode = EnumDeclarationNode::fromString( |
| 89 | + 'enum SomeEnum { A }' |
| 90 | + ); |
| 91 | + $enumStaticType = EnumStaticType::fromModuleIdAndDeclaration( |
| 92 | + ModuleId::fromString("module-a"), |
| 93 | + $enumDeclarationNode |
| 94 | + ); |
| 95 | + |
| 96 | + $enumInstanceType = $enumStaticType->toEnumInstanceType(); |
| 97 | + |
| 98 | + $this->assertInstanceOf(EnumInstanceType::class, $enumInstanceType); |
| 99 | + } |
| 100 | + |
| 101 | + /** |
| 102 | + * @test |
| 103 | + * @return void |
| 104 | + */ |
| 105 | + public function canBeComparedToOther(): void |
| 106 | + { |
| 107 | + $enumDeclarationNode = EnumDeclarationNode::fromString( |
| 108 | + 'enum SomeEnum { A }' |
| 109 | + ); |
| 110 | + $enumStaticType = EnumStaticType::fromModuleIdAndDeclaration( |
| 111 | + ModuleId::fromString("module-a"), |
| 112 | + $enumDeclarationNode |
| 113 | + ); |
| 114 | + |
| 115 | + $this->assertTrue($enumStaticType->is($enumStaticType)); |
| 116 | + |
| 117 | + $enumInstanceType = EnumInstanceType::fromModuleIdAndDeclaration( |
| 118 | + ModuleId::fromString("module-a"), |
| 119 | + $enumDeclarationNode |
| 120 | + ); |
| 121 | + |
| 122 | + $this->assertTrue($enumStaticType->is($enumInstanceType)); |
| 123 | + } |
65 | 124 | } |
0 commit comments