File tree Expand file tree Collapse file tree 4 files changed +23
-2
lines changed
src/phpDocumentor/Reflection/Php
unit/phpDocumentor/Reflection/Php Expand file tree Collapse file tree 4 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ public static function generatePlaceholder(string $name): string
8787 /** @param array<string, Fqsen|Type> $parts */
8888 public function __construct (string $ expression , array $ parts = [])
8989 {
90- Assert::notEmpty ($ expression );
90+ Assert::stringNotEmpty ($ expression );
9191 Assert::allIsInstanceOfAny ($ parts , [Fqsen::class, Type::class]);
9292
9393 $ this ->expression = $ expression ;
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ public function testEnumWithConstant(): void
6161
6262 $ enum = $ file ->getEnums ()['\MyNamespace\MyEnumWithConstant ' ];
6363 self ::assertInstanceOf (Enum_::class, $ enum );
64- self ::assertCount (1 , $ enum ->getConstants ());
64+ self ::assertCount (2 , $ enum ->getConstants ());
6565 self ::assertArrayHasKey ('\MyNamespace\MyEnumWithConstant::MYCONST ' , $ enum ->getConstants ());
6666 self ::assertSame ("'MyConstValue' " , $ enum ->getConstants ()['\MyNamespace\MyEnumWithConstant::MYCONST ' ]->getValue ());
6767 }
Original file line number Diff line number Diff line change 77enum MyEnumWithConstant
88{
99 public const MYCONST = 'MyConstValue ' ;
10+
11+ public const INT_CONST = 0 ;
1012}
Original file line number Diff line number Diff line change 1313
1414namespace phpDocumentor \Reflection \Php ;
1515
16+ use Generator ;
1617use InvalidArgumentException ;
1718use phpDocumentor \Reflection \Fqsen ;
1819use PHPUnit \Framework \Attributes \CoversClass ;
20+ use PHPUnit \Framework \Attributes \DataProvider ;
1921use PHPUnit \Framework \TestCase ;
2022
2123use function sprintf ;
@@ -110,4 +112,21 @@ public function testOverridePartsWhenRenderingExpression(): void
110112
111113 self ::assertSame (sprintf ('This is an %s expression ' , $ replacement ), $ result );
112114 }
115+
116+ #[DataProvider('expressionValues ' )]
117+ public function testExpressionTemplateCreation (string $ expression ): void
118+ {
119+ $ actual = new Expression ($ expression , []);
120+ self ::assertSame ($ expression , $ actual ->getExpression ());
121+ }
122+
123+ /** @return Generator<string, array{expression: string} */
124+ public static function expressionValues (): Generator
125+ {
126+ $ values = ['0 ' , 'null ' , 'false ' ];
127+
128+ foreach ($ values as $ value ) {
129+ yield $ value => ['expression ' => $ value ];
130+ }
131+ }
113132}
You can’t perform that action at this time.
0 commit comments