diff --git a/tests/unit/PseudoTypes/ArrayShapeItemTest.php b/tests/unit/PseudoTypes/ArrayShapeItemTest.php index 4bfd180..4d31cb5 100644 --- a/tests/unit/PseudoTypes/ArrayShapeItemTest.php +++ b/tests/unit/PseudoTypes/ArrayShapeItemTest.php @@ -15,7 +15,7 @@ use PHPUnit\Framework\TestCase; -class ArrayShapeItemTest extends TestCase +final class ArrayShapeItemTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/ArrayShapeTest.php b/tests/unit/PseudoTypes/ArrayShapeTest.php index 47488b0..804b74b 100644 --- a/tests/unit/PseudoTypes/ArrayShapeTest.php +++ b/tests/unit/PseudoTypes/ArrayShapeTest.php @@ -8,7 +8,7 @@ use phpDocumentor\Reflection\Types\Mixed_; use PHPUnit\Framework\TestCase; -class ArrayShapeTest extends TestCase +final class ArrayShapeTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/CallableStringTest.php b/tests/unit/PseudoTypes/CallableStringTest.php index 5134b5a..1bcd23c 100644 --- a/tests/unit/PseudoTypes/CallableStringTest.php +++ b/tests/unit/PseudoTypes/CallableStringTest.php @@ -16,7 +16,7 @@ use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; -class CallableStringTest extends TestCase +final class CallableStringTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/ClassStringTest.php b/tests/unit/PseudoTypes/ClassStringTest.php index 3e578c2..d087d38 100644 --- a/tests/unit/PseudoTypes/ClassStringTest.php +++ b/tests/unit/PseudoTypes/ClassStringTest.php @@ -19,7 +19,7 @@ use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; -class ClassStringTest extends TestCase +final class ClassStringTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/ConditionalForParameterTest.php b/tests/unit/PseudoTypes/ConditionalForParameterTest.php index 5a82240..b76c619 100644 --- a/tests/unit/PseudoTypes/ConditionalForParameterTest.php +++ b/tests/unit/PseudoTypes/ConditionalForParameterTest.php @@ -10,7 +10,7 @@ use phpDocumentor\Reflection\Types\Static_; use PHPUnit\Framework\TestCase; -class ConditionalForParameterTest extends TestCase +final class ConditionalForParameterTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/ConditionalTest.php b/tests/unit/PseudoTypes/ConditionalTest.php index 0093868..ba010d6 100644 --- a/tests/unit/PseudoTypes/ConditionalTest.php +++ b/tests/unit/PseudoTypes/ConditionalTest.php @@ -12,7 +12,7 @@ use phpDocumentor\Reflection\Types\Static_; use PHPUnit\Framework\TestCase; -class ConditionalTest extends TestCase +final class ConditionalTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/ConstExpressionTest.php b/tests/unit/PseudoTypes/ConstExpressionTest.php index b26ca28..7b048e1 100644 --- a/tests/unit/PseudoTypes/ConstExpressionTest.php +++ b/tests/unit/PseudoTypes/ConstExpressionTest.php @@ -18,7 +18,7 @@ use phpDocumentor\Reflection\Types\Object_; use PHPUnit\Framework\TestCase; -class ConstExpressionTest extends TestCase +final class ConstExpressionTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/EnumStringTest.php b/tests/unit/PseudoTypes/EnumStringTest.php index 9645e5d..d9c1dd6 100644 --- a/tests/unit/PseudoTypes/EnumStringTest.php +++ b/tests/unit/PseudoTypes/EnumStringTest.php @@ -19,7 +19,7 @@ use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; -class EnumStringTest extends TestCase +final class EnumStringTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/FloatValueTest.php b/tests/unit/PseudoTypes/FloatValueTest.php index 1d5db38..5df2817 100644 --- a/tests/unit/PseudoTypes/FloatValueTest.php +++ b/tests/unit/PseudoTypes/FloatValueTest.php @@ -16,7 +16,7 @@ use phpDocumentor\Reflection\Types\Float_; use PHPUnit\Framework\TestCase; -class FloatValueTest extends TestCase +final class FloatValueTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/GenericTest.php b/tests/unit/PseudoTypes/GenericTest.php index ff7880b..fe240dd 100644 --- a/tests/unit/PseudoTypes/GenericTest.php +++ b/tests/unit/PseudoTypes/GenericTest.php @@ -11,7 +11,7 @@ use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; -class GenericTest extends TestCase +final class GenericTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/HtmlEscapedStringTest.php b/tests/unit/PseudoTypes/HtmlEscapedStringTest.php index eeb635a..c628d4c 100644 --- a/tests/unit/PseudoTypes/HtmlEscapedStringTest.php +++ b/tests/unit/PseudoTypes/HtmlEscapedStringTest.php @@ -16,7 +16,7 @@ use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; -class HtmlEscapedStringTest extends TestCase +final class HtmlEscapedStringTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/IntMaskOfTest.php b/tests/unit/PseudoTypes/IntMaskOfTest.php index 68eaa01..e103549 100644 --- a/tests/unit/PseudoTypes/IntMaskOfTest.php +++ b/tests/unit/PseudoTypes/IntMaskOfTest.php @@ -8,7 +8,7 @@ use phpDocumentor\Reflection\Types\Integer; use PHPUnit\Framework\TestCase; -class IntMaskOfTest extends TestCase +final class IntMaskOfTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/IntMaskTest.php b/tests/unit/PseudoTypes/IntMaskTest.php index cdeaee8..6b2dee2 100644 --- a/tests/unit/PseudoTypes/IntMaskTest.php +++ b/tests/unit/PseudoTypes/IntMaskTest.php @@ -7,7 +7,7 @@ use phpDocumentor\Reflection\Types\Integer; use PHPUnit\Framework\TestCase; -class IntMaskTest extends TestCase +final class IntMaskTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/IntegerRangeTest.php b/tests/unit/PseudoTypes/IntegerRangeTest.php index 09bf27f..81a6926 100644 --- a/tests/unit/PseudoTypes/IntegerRangeTest.php +++ b/tests/unit/PseudoTypes/IntegerRangeTest.php @@ -16,7 +16,7 @@ use phpDocumentor\Reflection\Types\Integer; use PHPUnit\Framework\TestCase; -class IntegerRangeTest extends TestCase +final class IntegerRangeTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/IntegerValueTest.php b/tests/unit/PseudoTypes/IntegerValueTest.php index fcc441f..8f638ab 100644 --- a/tests/unit/PseudoTypes/IntegerValueTest.php +++ b/tests/unit/PseudoTypes/IntegerValueTest.php @@ -16,7 +16,7 @@ use phpDocumentor\Reflection\Types\Integer; use PHPUnit\Framework\TestCase; -class IntegerValueTest extends TestCase +final class IntegerValueTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/InterfaceStringTest.php b/tests/unit/PseudoTypes/InterfaceStringTest.php index a56823e..83621d8 100644 --- a/tests/unit/PseudoTypes/InterfaceStringTest.php +++ b/tests/unit/PseudoTypes/InterfaceStringTest.php @@ -19,7 +19,7 @@ use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; -class InterfaceStringTest extends TestCase +final class InterfaceStringTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/KeyOfTest.php b/tests/unit/PseudoTypes/KeyOfTest.php index 001d0ab..9171518 100644 --- a/tests/unit/PseudoTypes/KeyOfTest.php +++ b/tests/unit/PseudoTypes/KeyOfTest.php @@ -8,7 +8,7 @@ use phpDocumentor\Reflection\Types\Object_; use PHPUnit\Framework\TestCase; -class KeyOfTest extends TestCase +final class KeyOfTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/ListShapeTest.php b/tests/unit/PseudoTypes/ListShapeTest.php index 034acd6..593a440 100644 --- a/tests/unit/PseudoTypes/ListShapeTest.php +++ b/tests/unit/PseudoTypes/ListShapeTest.php @@ -15,7 +15,7 @@ use PHPUnit\Framework\TestCase; -class ListShapeTest extends TestCase +final class ListShapeTest extends TestCase { public function testToString(): void { diff --git a/tests/unit/PseudoTypes/ListTest.php b/tests/unit/PseudoTypes/ListTest.php index 8f51c51..dbb0cf5 100644 --- a/tests/unit/PseudoTypes/ListTest.php +++ b/tests/unit/PseudoTypes/ListTest.php @@ -20,7 +20,7 @@ use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; -class ListTest extends TestCase +final class ListTest extends TestCase { public function testCreateWithoutParams(): void { diff --git a/tests/unit/PseudoTypes/LiteralStringTest.php b/tests/unit/PseudoTypes/LiteralStringTest.php index ef5131f..4354122 100644 --- a/tests/unit/PseudoTypes/LiteralStringTest.php +++ b/tests/unit/PseudoTypes/LiteralStringTest.php @@ -16,7 +16,7 @@ use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; -class LiteralStringTest extends TestCase +final class LiteralStringTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/LowercaseStringTest.php b/tests/unit/PseudoTypes/LowercaseStringTest.php index 8f358fd..86bb970 100644 --- a/tests/unit/PseudoTypes/LowercaseStringTest.php +++ b/tests/unit/PseudoTypes/LowercaseStringTest.php @@ -16,7 +16,7 @@ use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; -class LowercaseStringTest extends TestCase +final class LowercaseStringTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/NegativeIntegerTest.php b/tests/unit/PseudoTypes/NegativeIntegerTest.php index 8c889d3..fe991a5 100644 --- a/tests/unit/PseudoTypes/NegativeIntegerTest.php +++ b/tests/unit/PseudoTypes/NegativeIntegerTest.php @@ -16,7 +16,7 @@ use phpDocumentor\Reflection\Types\Integer; use PHPUnit\Framework\TestCase; -class NegativeIntegerTest extends TestCase +final class NegativeIntegerTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/NonEmptyArrayTest.php b/tests/unit/PseudoTypes/NonEmptyArrayTest.php index 0531179..bc3bc18 100644 --- a/tests/unit/PseudoTypes/NonEmptyArrayTest.php +++ b/tests/unit/PseudoTypes/NonEmptyArrayTest.php @@ -20,7 +20,7 @@ use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; -class NonEmptyArrayTest extends TestCase +final class NonEmptyArrayTest extends TestCase { public function testCreateWithoutParams(): void { diff --git a/tests/unit/PseudoTypes/NonEmptyListTest.php b/tests/unit/PseudoTypes/NonEmptyListTest.php index 75cd2f6..d6f3d33 100644 --- a/tests/unit/PseudoTypes/NonEmptyListTest.php +++ b/tests/unit/PseudoTypes/NonEmptyListTest.php @@ -20,7 +20,7 @@ use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; -class NonEmptyListTest extends TestCase +final class NonEmptyListTest extends TestCase { public function testCreateWithoutParams(): void { diff --git a/tests/unit/PseudoTypes/NonEmptyLowercaseStringTest.php b/tests/unit/PseudoTypes/NonEmptyLowercaseStringTest.php index 291f856..9e84b37 100644 --- a/tests/unit/PseudoTypes/NonEmptyLowercaseStringTest.php +++ b/tests/unit/PseudoTypes/NonEmptyLowercaseStringTest.php @@ -16,7 +16,7 @@ use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; -class NonEmptyLowercaseStringTest extends TestCase +final class NonEmptyLowercaseStringTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/NonEmptyStringTest.php b/tests/unit/PseudoTypes/NonEmptyStringTest.php index 9dc9226..48c2b64 100644 --- a/tests/unit/PseudoTypes/NonEmptyStringTest.php +++ b/tests/unit/PseudoTypes/NonEmptyStringTest.php @@ -16,7 +16,7 @@ use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; -class NonEmptyStringTest extends TestCase +final class NonEmptyStringTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/NumericStringTest.php b/tests/unit/PseudoTypes/NumericStringTest.php index c3b9a8b..32d9377 100644 --- a/tests/unit/PseudoTypes/NumericStringTest.php +++ b/tests/unit/PseudoTypes/NumericStringTest.php @@ -16,7 +16,7 @@ use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; -class NumericStringTest extends TestCase +final class NumericStringTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/ObjectShapeTest.php b/tests/unit/PseudoTypes/ObjectShapeTest.php index b5c6268..8d8f50d 100644 --- a/tests/unit/PseudoTypes/ObjectShapeTest.php +++ b/tests/unit/PseudoTypes/ObjectShapeTest.php @@ -7,7 +7,7 @@ use phpDocumentor\Reflection\Types\Object_; use PHPUnit\Framework\TestCase; -class ObjectShapeTest extends TestCase +final class ObjectShapeTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/OffsetAccessTest.php b/tests/unit/PseudoTypes/OffsetAccessTest.php index ccb354f..99c2dcb 100644 --- a/tests/unit/PseudoTypes/OffsetAccessTest.php +++ b/tests/unit/PseudoTypes/OffsetAccessTest.php @@ -9,7 +9,7 @@ use phpDocumentor\Reflection\Types\Object_; use PHPUnit\Framework\TestCase; -class OffsetAccessTest extends TestCase +final class OffsetAccessTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/PositiveIntegerTest.php b/tests/unit/PseudoTypes/PositiveIntegerTest.php index 385e02a..e348062 100644 --- a/tests/unit/PseudoTypes/PositiveIntegerTest.php +++ b/tests/unit/PseudoTypes/PositiveIntegerTest.php @@ -16,7 +16,7 @@ use phpDocumentor\Reflection\Types\Integer; use PHPUnit\Framework\TestCase; -class PositiveIntegerTest extends TestCase +final class PositiveIntegerTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/StringValueTest.php b/tests/unit/PseudoTypes/StringValueTest.php index 5c582de..fd9b4be 100644 --- a/tests/unit/PseudoTypes/StringValueTest.php +++ b/tests/unit/PseudoTypes/StringValueTest.php @@ -16,7 +16,7 @@ use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; -class StringValueTest extends TestCase +final class StringValueTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/TraitStringTest.php b/tests/unit/PseudoTypes/TraitStringTest.php index 22ca0c1..5b105ed 100644 --- a/tests/unit/PseudoTypes/TraitStringTest.php +++ b/tests/unit/PseudoTypes/TraitStringTest.php @@ -19,7 +19,7 @@ use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; -class TraitStringTest extends TestCase +final class TraitStringTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/PseudoTypes/TrueTest.php b/tests/unit/PseudoTypes/TrueTest.php index 87f29c8..ef14cbf 100644 --- a/tests/unit/PseudoTypes/TrueTest.php +++ b/tests/unit/PseudoTypes/TrueTest.php @@ -16,7 +16,7 @@ use phpDocumentor\Reflection\Types\Boolean; use PHPUnit\Framework\TestCase; -class TrueTest extends TestCase +final class TrueTest extends TestCase { public function testExposesUnderlyingType(): void { diff --git a/tests/unit/PseudoTypes/ValueOfTest.php b/tests/unit/PseudoTypes/ValueOfTest.php index 9a1b7d1..8421d02 100644 --- a/tests/unit/PseudoTypes/ValueOfTest.php +++ b/tests/unit/PseudoTypes/ValueOfTest.php @@ -9,7 +9,7 @@ use phpDocumentor\Reflection\Types\Object_; use PHPUnit\Framework\TestCase; -class ValueOfTest extends TestCase +final class ValueOfTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/TypeResolverTest.php b/tests/unit/TypeResolverTest.php index 61ce547..4cd94f4 100644 --- a/tests/unit/TypeResolverTest.php +++ b/tests/unit/TypeResolverTest.php @@ -102,7 +102,9 @@ public function testResolvingKeywords(string $keyword, string $expectedClass): v $fixture = new TypeResolver(); $resolvedType = $fixture->resolve($keyword, new Context('')); + $this->assertInstanceOf($expectedClass, $resolvedType); + $resolvedType = $fixture->resolve($keyword); $this->assertInstanceOf($expectedClass, $resolvedType); } @@ -1339,4 +1341,11 @@ public function illegalLegacyFormatProvider(): array ], ]; } + + public function testCreateTypeFromNull(): void + { + $fixture = new TypeResolver(); + + $this->assertEquals(new Mixed_(), $fixture->createType(null, new Context(''))); + } } diff --git a/tests/unit/Types/ArrayTest.php b/tests/unit/Types/ArrayTest.php index 3dbc95f..3c567dd 100644 --- a/tests/unit/Types/ArrayTest.php +++ b/tests/unit/Types/ArrayTest.php @@ -16,7 +16,7 @@ use phpDocumentor\Reflection\Fqsen; use PHPUnit\Framework\TestCase; -class ArrayTest extends TestCase +final class ArrayTest extends TestCase { public function testCreateWithoutParams(): void { @@ -47,17 +47,17 @@ public function testCreateWithParams(): void } /** - * @dataProvider provideArrays + * @dataProvider provideToStringData */ - public function testArrayStringifyCorrectly(Array_ $array, string $expectedString): void + public function testToString(Array_ $array, string $expectedString): void { $this->assertSame($expectedString, (string) $array); } /** - * @return mixed[] + * @return array */ - public function provideArrays(): array + public function provideToStringData(): array { return [ 'simple array' => [new Array_(), 'array'], diff --git a/tests/unit/Types/BooleanTest.php b/tests/unit/Types/BooleanTest.php index 59ec11c..d1ddbf3 100644 --- a/tests/unit/Types/BooleanTest.php +++ b/tests/unit/Types/BooleanTest.php @@ -17,7 +17,7 @@ final class BooleanTest extends TestCase { - public function testBooleanStringifyCorrectly(): void + public function testToString(): void { $type = new Boolean(); diff --git a/tests/unit/Types/CallableParameterTest.php b/tests/unit/Types/CallableParameterTest.php new file mode 100644 index 0000000..b88de69 --- /dev/null +++ b/tests/unit/Types/CallableParameterTest.php @@ -0,0 +1,39 @@ +assertSame($type, $parameter->getType()); + $this->assertSame($name, $parameter->getName()); + $this->assertTrue($parameter->isOptional()); + $this->assertTrue($parameter->isReference()); + $this->assertTrue($parameter->isVariadic()); + } +} diff --git a/tests/unit/Types/CompoundTest.php b/tests/unit/Types/CompoundTest.php index 1a74b8f..40a2763 100644 --- a/tests/unit/Types/CompoundTest.php +++ b/tests/unit/Types/CompoundTest.php @@ -87,7 +87,7 @@ public function testCompoundDoesNotContainType(): void * @uses \phpDocumentor\Reflection\Types\Integer * @uses \phpDocumentor\Reflection\Types\Boolean */ - public function testCompoundCanBeConstructedAndStringifiedCorrectly(): void + public function testToString(): void { $this->assertSame('int|bool', (string) (new Compound([new Integer(), new Boolean()]))); } diff --git a/tests/unit/Types/ContextFactoryTest.php b/tests/unit/Types/ContextFactoryTest.php index 8e0f812..5d9a13e 100644 --- a/tests/unit/Types/ContextFactoryTest.php +++ b/tests/unit/Types/ContextFactoryTest.php @@ -20,29 +20,75 @@ Exception as e }; use \ReflectionClass; + use ReflectionClassConstant; + use ReflectionMethod; + use ReflectionParameter; + use ReflectionProperty; use stdClass; class ContextFactoryTest extends TestCase { + public const TEST_CONSTANT = ''; + + public string $testProperty = ''; + /** * @uses phpDocumentor\Reflection\Types\Context */ - public function testReadsNamespaceFromClassReflection() : void + public function testCreateFromClassReflection() : void { $fixture = new ContextFactory(); $context = $fixture->createFromReflector(new ReflectionClass($this)); $this->assertSame(__NAMESPACE__, $context->getNamespace()); + $this->assertNamespaceAliasesFrom($context); } /** * @uses phpDocumentor\Reflection\Types\Context */ - public function testReadsAliasesFromClassReflection() : void + public function testCreateFromMethodReflection() : void { $fixture = new ContextFactory(); - $context = $fixture->createFromReflector(new ReflectionClass($this)); + $context = $fixture->createFromReflector(new ReflectionMethod($this, 'testCreateFromMethodReflection')); + + $this->assertSame(__NAMESPACE__, $context->getNamespace()); + $this->assertNamespaceAliasesFrom($context); + } + + /** + * @uses phpDocumentor\Reflection\Types\Context + */ + public function testCreateFromPropertyReflection() : void + { + $fixture = new ContextFactory(); + $context = $fixture->createFromReflector(new ReflectionProperty($this, 'testProperty')); + + $this->assertSame(__NAMESPACE__, $context->getNamespace()); + $this->assertNamespaceAliasesFrom($context); + } + /** + * @uses phpDocumentor\Reflection\Types\Context + */ + public function testCreateFromClassConstantReflection() : void + { + $fixture = new ContextFactory(); + $context = $fixture->createFromReflector(new ReflectionClassConstant($this, 'TEST_CONSTANT')); + + $this->assertSame(__NAMESPACE__, $context->getNamespace()); + $this->assertNamespaceAliasesFrom($context); + } + + /** + * @uses phpDocumentor\Reflection\Types\Context + */ + public function testCreateFromParameterReflection(): void + { + $fixture = new ContextFactory(); + $context = $fixture->createFromReflector(new ReflectionParameter(fn($param) => $param, 'param')); + + $this->assertSame(__NAMESPACE__, $context->getNamespace()); $this->assertNamespaceAliasesFrom($context); } @@ -168,7 +214,7 @@ public function testEvalDClass() : void eval(<< Assert::class, 'e' => e::class, ReflectionClass::class => ReflectionClass::class, + ReflectionMethod::class => ReflectionMethod::class, + ReflectionProperty::class => ReflectionProperty::class, + ReflectionClassConstant::class => ReflectionClassConstant::class, + ReflectionParameter::class => ReflectionParameter::class, \stdClass::class => \stdClass::class, ]; diff --git a/tests/unit/Types/ContextTest.php b/tests/unit/Types/ContextTest.php index 6695d5c..59578af 100644 --- a/tests/unit/Types/ContextTest.php +++ b/tests/unit/Types/ContextTest.php @@ -15,7 +15,7 @@ use PHPUnit\Framework\TestCase; -class ContextTest extends TestCase +final class ContextTest extends TestCase { public function testProvidesANormalizedNamespace(): void { @@ -39,5 +39,8 @@ public function testProvidesNormalizedNamespaceAliases(): void { $fixture = new Context('', ['Space' => '\My\Space']); $this->assertSame(['Space' => 'My\Space'], $fixture->getNamespaceAliases()); + + $fixture = new Context('', ['Space' => '\My\Space\\']); + $this->assertSame(['Space' => 'My\Space'], $fixture->getNamespaceAliases()); } } diff --git a/tests/unit/Types/IterableTest.php b/tests/unit/Types/IterableTest.php index 72a1a84..d43216b 100644 --- a/tests/unit/Types/IterableTest.php +++ b/tests/unit/Types/IterableTest.php @@ -15,20 +15,20 @@ use PHPUnit\Framework\TestCase; -class IterableTest extends TestCase +final class IterableTest extends TestCase { /** - * @dataProvider provideIterables + * @dataProvider provideToStringData */ - public function testIterableStringifyCorrectly(Iterable_ $iterable, string $expectedString): void + public function testToString(Iterable_ $iterable, string $expectedString): void { $this->assertSame($expectedString, (string) $iterable); } /** - * @return mixed[] + * @return array */ - public function provideIterables(): array + public function provideToStringData(): array { return [ 'simple iterable' => [new Iterable_(), 'iterable'], diff --git a/tests/unit/Types/NeverTest.php b/tests/unit/Types/NeverTest.php new file mode 100644 index 0000000..4731b4a --- /dev/null +++ b/tests/unit/Types/NeverTest.php @@ -0,0 +1,26 @@ +assertSame('never', (string) $type); + } +} diff --git a/tests/unit/Types/NullableTest.php b/tests/unit/Types/NullableTest.php index 401a1de..977400b 100644 --- a/tests/unit/Types/NullableTest.php +++ b/tests/unit/Types/NullableTest.php @@ -15,9 +15,9 @@ use PHPUnit\Framework\TestCase; -class NullableTest extends TestCase +final class NullableTest extends TestCase { - public function testNullableTypeWrapsCorrectly(): void + public function testCreate(): void { $realType = new String_(); @@ -26,7 +26,7 @@ public function testNullableTypeWrapsCorrectly(): void $this->assertSame($realType, $nullableString->getActualType()); } - public function testNullableStringifyCorrectly(): void + public function testToString(): void { $this->assertSame('?string', (string) new Nullable(new String_())); } diff --git a/tests/unit/Types/ObjectTest.php b/tests/unit/Types/ObjectTest.php new file mode 100644 index 0000000..ad44b8d --- /dev/null +++ b/tests/unit/Types/ObjectTest.php @@ -0,0 +1,35 @@ +expectExceptionObject( + new InvalidArgumentException( + 'Object types can only refer to a class, interface or trait but a method, function, constant or ' + . 'property was received: ' . (string) $fqsen + ) + ); + + new Object_($fqsen); + } +} diff --git a/tests/unit/Types/ParentTest.php b/tests/unit/Types/ParentTest.php new file mode 100644 index 0000000..f2c59f5 --- /dev/null +++ b/tests/unit/Types/ParentTest.php @@ -0,0 +1,26 @@ +assertSame('parent', (string) $type); + } +} diff --git a/tests/unit/Types/ResourceTest.php b/tests/unit/Types/ResourceTest.php new file mode 100644 index 0000000..d397ffd --- /dev/null +++ b/tests/unit/Types/ResourceTest.php @@ -0,0 +1,26 @@ +assertSame('resource', (string) $type); + } +} diff --git a/tests/unit/Types/ScalarTest.php b/tests/unit/Types/ScalarTest.php new file mode 100644 index 0000000..aacd94d --- /dev/null +++ b/tests/unit/Types/ScalarTest.php @@ -0,0 +1,26 @@ +assertSame('scalar', (string) $type); + } +} diff --git a/tests/unit/Types/SelfTest.php b/tests/unit/Types/SelfTest.php index 34a64ab..d69fbb5 100644 --- a/tests/unit/Types/SelfTest.php +++ b/tests/unit/Types/SelfTest.php @@ -7,7 +7,7 @@ use phpDocumentor\Reflection\Fqsen; use PHPUnit\Framework\TestCase; -class SelfTest extends TestCase +final class SelfTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/Types/StaticTest.php b/tests/unit/Types/StaticTest.php index 719c32e..53f6f18 100644 --- a/tests/unit/Types/StaticTest.php +++ b/tests/unit/Types/StaticTest.php @@ -7,7 +7,7 @@ use phpDocumentor\Reflection\Fqsen; use PHPUnit\Framework\TestCase; -class StaticTest extends TestCase +final class StaticTest extends TestCase { public function testCreate(): void { diff --git a/tests/unit/Types/ThisTest.php b/tests/unit/Types/ThisTest.php new file mode 100644 index 0000000..a856a3b --- /dev/null +++ b/tests/unit/Types/ThisTest.php @@ -0,0 +1,26 @@ +assertSame('$this', (string) $type); + } +} diff --git a/tests/unit/Types/VoidTest.php b/tests/unit/Types/VoidTest.php new file mode 100644 index 0000000..a82e86b --- /dev/null +++ b/tests/unit/Types/VoidTest.php @@ -0,0 +1,26 @@ +assertSame('void', (string) $type); + } +}