AnnotationTest.php 879 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace EasySwoole\Annotation\Tests;
  3. use EasySwoole\Annotation\Annotation;
  4. use EasySwoole\Annotation\Tests\Tag\TestTagOne;
  5. use EasySwoole\Annotation\Tests\Tag\TestTagTwo;
  6. use PHPUnit\Framework\TestCase;
  7. class AnnotationTest extends TestCase
  8. {
  9. private $annotation;
  10. /**
  11. * @TestTagOne(key="myKey");
  12. */
  13. private $property;
  14. function __construct($name = null, array $data = [], $dataName = '')
  15. {
  16. $this->annotation = new Annotation();
  17. $this->annotation->addParserTag(new TestTagOne());
  18. $this->annotation->addParserTag(new TestTagTwo());
  19. parent::__construct($name, $data, $dataName);
  20. }
  21. function testProperty()
  22. {
  23. $ret = $this->annotation->getAnnotation((new \ReflectionClass(static::class))->getProperty('property'));
  24. $this->assertEquals('myKey',$ret['TestTagOne'][0]->key);
  25. }
  26. }