ClassConstTest.php 897 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\Node\Stmt;
  3. class ClassConstTest extends \PHPUnit\Framework\TestCase
  4. {
  5. /**
  6. * @dataProvider provideModifiers
  7. */
  8. public function testModifiers($modifier) {
  9. $node = new ClassConst(
  10. [], // invalid
  11. constant('PhpParser\Node\Stmt\Class_::MODIFIER_' . strtoupper($modifier))
  12. );
  13. $this->assertTrue($node->{'is' . $modifier}());
  14. }
  15. public function testNoModifiers() {
  16. $node = new ClassConst([], 0);
  17. $this->assertTrue($node->isPublic());
  18. $this->assertFalse($node->isProtected());
  19. $this->assertFalse($node->isPrivate());
  20. $this->assertFalse($node->isFinal());
  21. }
  22. public function provideModifiers() {
  23. return [
  24. ['public'],
  25. ['protected'],
  26. ['private'],
  27. ['final'],
  28. ];
  29. }
  30. }