DCOM141Test.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace EasySwoole\DoctrineAnnotation\Tests\Ticket;
  3. use EasySwoole\DoctrineAnnotation\AnnotationReader;
  4. use PHPUnit\Framework\TestCase;
  5. use ReflectionClass;
  6. /**
  7. * @group
  8. */
  9. class DCOM141Test extends TestCase
  10. {
  11. public function testAnnotationPrefixed(): void
  12. {
  13. $class = new ReflectionClass(DCOM141ConsumerPrefixed::class);
  14. $reader = new AnnotationReader();
  15. $annots = $reader->getClassAnnotations($class);
  16. self::assertCount(1, $annots);
  17. self::assertInstanceOf(DCOM141Annotation::class, $annots[0]);
  18. self::assertEquals('SimpleXMLElement', $annots[0]->classPath);
  19. }
  20. public function testAnnotationNotPrefixed(): void
  21. {
  22. $class = new ReflectionClass(DCOM141ConsumerNotPrefixed::class);
  23. $reader = new AnnotationReader();
  24. $annots = $reader->getClassAnnotations($class);
  25. self::assertCount(1, $annots);
  26. self::assertInstanceOf(DCOM141Annotation::class, $annots[0]);
  27. self::assertEquals('SimpleXMLElement', $annots[0]->classPath);
  28. }
  29. }
  30. /**
  31. * @Annotation
  32. */
  33. class DCOM141Annotation
  34. {
  35. /** @var mixed */
  36. public $classPath;
  37. }
  38. /**
  39. * @DCOM141Annotation(\SimpleXMLElement::class)
  40. */
  41. class DCOM141ConsumerPrefixed
  42. {
  43. }
  44. /**
  45. * @DCOM141Annotation(SimpleXMLElement::class)
  46. */
  47. class DCOM141ConsumerNotPrefixed
  48. {
  49. }