SimpleAnnotationReaderTest.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace Doctrine\Tests\Common\Annotations;
  3. use Doctrine\Common\Annotations\SimpleAnnotationReader;
  4. class SimpleAnnotationReaderTest extends AbstractReaderTest
  5. {
  6. /**
  7. * Contrary to the behavior of the default annotation reader, we do just ignore
  8. * these in the simple annotation reader (so, no expected exception here).
  9. */
  10. public function testImportDetectsNotImportedAnnotation()
  11. {
  12. parent::testImportDetectsNotImportedAnnotation();
  13. }
  14. /**
  15. * Contrary to the behavior of the default annotation reader, we do just ignore
  16. * these in the simple annotation reader (so, no expected exception here).
  17. */
  18. public function testImportDetectsNonExistentAnnotation()
  19. {
  20. parent::testImportDetectsNonExistentAnnotation();
  21. }
  22. /**
  23. * Contrary to the behavior of the default annotation reader, we do just ignore
  24. * these in the simple annotation reader (so, no expected exception here).
  25. */
  26. public function testClassWithInvalidAnnotationTargetAtClassDocBlock()
  27. {
  28. parent::testClassWithInvalidAnnotationTargetAtClassDocBlock();
  29. }
  30. /**
  31. * Contrary to the behavior of the default annotation reader, we do just ignore
  32. * these in the simple annotation reader (so, no expected exception here).
  33. */
  34. public function testClassWithInvalidAnnotationTargetAtPropertyDocBlock()
  35. {
  36. parent::testClassWithInvalidAnnotationTargetAtPropertyDocBlock();
  37. }
  38. /**
  39. * Contrary to the behavior of the default annotation reader, we do just ignore
  40. * these in the simple annotation reader (so, no expected exception here).
  41. */
  42. public function testClassWithInvalidNestedAnnotationTargetAtPropertyDocBlock()
  43. {
  44. parent::testClassWithInvalidNestedAnnotationTargetAtPropertyDocBlock();
  45. }
  46. /**
  47. * Contrary to the behavior of the default annotation reader, we do just ignore
  48. * these in the simple annotation reader (so, no expected exception here).
  49. */
  50. public function testClassWithInvalidAnnotationTargetAtMethodDocBlock()
  51. {
  52. parent::testClassWithInvalidAnnotationTargetAtMethodDocBlock();
  53. }
  54. /**
  55. * @expectedException Doctrine\Common\Annotations\AnnotationException
  56. */
  57. public function testInvalidAnnotationUsageButIgnoredClass()
  58. {
  59. parent::testInvalidAnnotationUsageButIgnoredClass();
  60. }
  61. /**
  62. * @group DDC-1660
  63. * @group regression
  64. *
  65. * Contrary to the behavior of the default annotation reader, @version is not ignored
  66. */
  67. public function testInvalidAnnotationButIgnored()
  68. {
  69. $reader = $this->getReader();
  70. $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassDDC1660');
  71. $this->assertTrue(class_exists('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Version'));
  72. $this->assertCount(1, $reader->getClassAnnotations($class));
  73. $this->assertCount(1, $reader->getMethodAnnotations($class->getMethod('bar')));
  74. $this->assertCount(1, $reader->getPropertyAnnotations($class->getProperty('foo')));
  75. }
  76. protected function getReader()
  77. {
  78. $reader = new SimpleAnnotationReader();
  79. $reader->addNamespace(__NAMESPACE__);
  80. $reader->addNamespace(__NAMESPACE__ . '\Fixtures');
  81. $reader->addNamespace(__NAMESPACE__ . '\Fixtures\Annotation');
  82. return $reader;
  83. }
  84. }