1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
<?php
namespace Doctrine\Tests\Common\Annotations;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Annotations\SimpleAnnotationReader;
use ReflectionClass;
use function class_exists;
class SimpleAnnotationReaderTest extends AbstractReaderTest
{
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*
* @doesNotPerformAssertions
*/
public function testImportDetectsNotImportedAnnotation(): void
{
$this->ignoreIssues();
parent::testImportDetectsNotImportedAnnotation();
}
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*
* @doesNotPerformAssertions
*/
public function testImportDetectsNonExistentAnnotation(): void
{
$this->ignoreIssues();
parent::testImportDetectsNonExistentAnnotation();
}
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*
* @doesNotPerformAssertions
*/
public function testClassWithInvalidAnnotationTargetAtClassDocBlock(): void
{
$this->ignoreIssues();
parent::testClassWithInvalidAnnotationTargetAtClassDocBlock();
}
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*
* @doesNotPerformAssertions
*/
public function testClassWithInvalidAnnotationTargetAtPropertyDocBlock(): void
{
$this->ignoreIssues();
parent::testClassWithInvalidAnnotationTargetAtPropertyDocBlock();
}
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*
* @doesNotPerformAssertions
*/
public function testClassWithInvalidNestedAnnotationTargetAtPropertyDocBlock(): void
{
$this->ignoreIssues();
parent::testClassWithInvalidNestedAnnotationTargetAtPropertyDocBlock();
}
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*
* @doesNotPerformAssertions
*/
public function testClassWithInvalidAnnotationTargetAtMethodDocBlock(): void
{
$this->ignoreIssues();
parent::testClassWithInvalidAnnotationTargetAtMethodDocBlock();
}
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*
* @doesNotPerformAssertions
*/
public function testErrorWhenInvalidAnnotationIsUsed(): void
{
$this->ignoreIssues();
parent::testErrorWhenInvalidAnnotationIsUsed();
}
/**
* The SimpleAnnotationReader doens't include the @IgnoreAnnotation in the results.
*/
public function testInvalidAnnotationUsageButIgnoredClass(): void
{
$reader = $this->getReader();
$ref = new ReflectionClass(Fixtures\InvalidAnnotationUsageButIgnoredClass::class);
$annots = $reader->getClassAnnotations($ref);
self::assertCount(1, $annots);
}
public function testIncludeIgnoreAnnotation(): void
{
$this->markTestSkipped('The simplified annotation reader would always autoload annotations');
}
/**
* @group DDC-1660
* @group regression
*
* Contrary to the behavior of the default annotation reader, @version is not ignored
*/
public function testInvalidAnnotationButIgnored(): void
{
$reader = $this->getReader();
$class = new ReflectionClass(Fixtures\ClassDDC1660::class);
self::assertTrue(class_exists(Fixtures\Annotation\Version::class));
self::assertCount(1, $reader->getClassAnnotations($class));
self::assertCount(1, $reader->getMethodAnnotations($class->getMethod('bar')));
self::assertCount(1, $reader->getPropertyAnnotations($class->getProperty('foo')));
}
protected function getReader(): Reader
{
$reader = new SimpleAnnotationReader();
$reader->addNamespace(__NAMESPACE__);
$reader->addNamespace(__NAMESPACE__ . '\Fixtures');
$reader->addNamespace(__NAMESPACE__ . '\Fixtures\Annotation');
return $reader;
}
}
|