AnnotationTest.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace EasySwoole\DoctrineAnnotation\Tests;
  3. use BadMethodCallException;
  4. use EasySwoole\DoctrineAnnotation\Annotation;
  5. use PHPUnit\Framework\TestCase;
  6. use function sprintf;
  7. final class AnnotationTest extends TestCase
  8. {
  9. public function testMagicGetThrowsBadMethodCallException(): void
  10. {
  11. $name = 'foo';
  12. $annotation = new Annotation([]);
  13. $this->expectException(BadMethodCallException::class);
  14. $this->expectExceptionMessage(sprintf(
  15. "Unknown property '%s' on annotation '%s'.",
  16. $name,
  17. Annotation::class
  18. ));
  19. $annotation->{$name};
  20. }
  21. public function testMagicSetThrowsBadMethodCallException(): void
  22. {
  23. $name = 'foo';
  24. $annotation = new Annotation([]);
  25. $this->expectException(BadMethodCallException::class);
  26. $this->expectExceptionMessage(sprintf(
  27. "Unknown property '%s' on annotation '%s'.",
  28. $name,
  29. Annotation::class
  30. ));
  31. $annotation->{$name} = 9001;
  32. }
  33. }