Skip to content

Commit 8e1cf65

Browse files
committed
Add regression test for ::class followed by enum case
1 parent ce24060 commit 8e1cf65

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

tests/Commands/GenerateInterfaceUnionsCommandTest.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ public function testCommandExports(): void
2121
$output = file_get_contents('./models/index.d.ts');
2222

2323
$this->assertIsString($output);
24-
$this->assertStringContainsString('"App\\\\Models\\\\AliasAnimal"', $output);
25-
$this->assertStringContainsString('"App\\\\Models\\\\AttributeClassReferenceAnimal"', $output);
26-
$this->assertStringContainsString('"App\\\\Models\\\\FullyQualifiedAnimal"', $output);
27-
$this->assertStringContainsString('"App\\\\Models\\\\GroupedUseAnimal"', $output);
28-
$this->assertStringContainsString('"App\\\\Models\\\\InheritedAnimal"', $output);
24+
$this->assertStringContainsString('"App\\Models\\AliasAnimal"', $output);
25+
$this->assertStringContainsString('"App\\Models\\AttributeClassReferenceAnimal"', $output);
26+
$this->assertStringContainsString('"App\\Models\\FullyQualifiedAnimal"', $output);
27+
$this->assertStringContainsString('"App\\Models\\GroupedUseAnimal"', $output);
28+
$this->assertStringContainsString('"App\\Models\\InheritedAnimal"', $output);
2929
}
3030

3131
public function testCommandExportsFullClassNameWhenDeclarationCrossesChunkBoundary(): void
@@ -53,7 +53,7 @@ public function testCommandExportsFullClassNameWhenDeclarationCrossesChunkBounda
5353

5454
$this->assertIsString($output);
5555
$this->assertStringContainsString(
56-
'"App\\\\Models\\\\SomeLongClassNameThatCrossesTheLegacyChunkBoundary"',
56+
'"App\\Models\\SomeLongClassNameThatCrossesTheLegacyChunkBoundary"',
5757
$output
5858
);
5959
}
@@ -121,6 +121,17 @@ public function testParserIgnoresClassConstantReferencesBeforeClassDeclaration()
121121
$this->assertSame(['App\\Interfaces\\AnimalInterface'], $info['implements']);
122122
}
123123

124+
public function testParserIgnoresClassConstantReferencesBeforeClassDeclarationWhenFollowedByEnumCase(): void
125+
{
126+
$info = $this->makeParserCommand()->classInfo(
127+
'./workbench/app/Models/AttributeClassAndEnumReferenceAnimal.php'
128+
);
129+
130+
$this->assertSame('AttributeClassAndEnumReferenceAnimal', $info['class']);
131+
$this->assertSame('App\\Models\\AttributeClassAndEnumReferenceAnimal', $info['fqcn']);
132+
$this->assertSame(['App\\Interfaces\\AnimalInterface'], $info['implements']);
133+
}
134+
124135
public function testCommandFailsForInvalidInputPath(): void
125136
{
126137
$this->expectException(\RuntimeException::class);
@@ -136,4 +147,4 @@ protected function makeParserCommand(): TestableGenerateInterfaceUnionsCommand
136147
{
137148
return new TestableGenerateInterfaceUnionsCommand(new Filesystem());
138149
}
139-
}
150+
}

0 commit comments

Comments
 (0)