diff --git a/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php index 5c8754295..fac260f97 100644 --- a/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php @@ -6,6 +6,8 @@ use Doctrine\Common\Annotations\DocParser; use Doctrine\Common\Annotations\Reader; use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\SingleUseAnnotation; +use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithEnumProperty; +use Doctrine\Tests\Common\Annotations\Fixtures\ClassWithEnumAnnotations; use Doctrine\Tests\Common\Annotations\Fixtures\ClassWithFullPathUseStatement; use Doctrine\Tests\Common\Annotations\Fixtures\ClassWithImportedIgnoredAnnotation; use Doctrine\Tests\Common\Annotations\Fixtures\ClassWithPHPCodeSnifferAnnotation; @@ -15,6 +17,7 @@ use Doctrine\Tests\Common\Annotations\Fixtures\IgnoredNamespaces\AnnotatedAtMethodLevel; use Doctrine\Tests\Common\Annotations\Fixtures\IgnoredNamespaces\AnnotatedAtPropertyLevel; use Doctrine\Tests\Common\Annotations\Fixtures\IgnoredNamespaces\AnnotatedWithAlias; +use Doctrine\Tests\Common\Annotations\Fixtures\Suit; use InvalidArgumentException; use LogicException; use ReflectionClass; @@ -295,4 +298,33 @@ public function testFunctionAnnotation(): void $annotation = $reader->getFunctionAnnotation($ref, Fixtures\Annotation\Autoload::class); self::assertInstanceOf(Fixtures\Annotation\Autoload::class, $annotation); } + + /** + * @requires PHP 8.1 + * @dataProvider provideEnumProperties + */ + public function testAnnotationWithEnum(string $property, Suit $expectedValue): void + { + $reader = $this->getReader(); + $ref = new ReflectionClass(ClassWithEnumAnnotations::class); + + $annotation = $reader->getPropertyAnnotation($ref->getProperty($property), AnnotationWithEnumProperty::class); + + self::assertSame($expectedValue, $annotation->suit); + } + + /** + * @return list + */ + public function provideEnumProperties(): array + { + if (PHP_VERSION_ID < 80100) { + return []; + } + + return [ + ['annotationWithDefaults', Suit::Hearts], + ['annotationWithSpades', Suit::Spades], + ]; + } } diff --git a/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithEnumProperty.php b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithEnumProperty.php new file mode 100644 index 000000000..97d299769 --- /dev/null +++ b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithEnumProperty.php @@ -0,0 +1,18 @@ +