ClassConstTest.php 828 B

12345678910111213141516171819202122232425262728293031323334
  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. }
  21. public function provideModifiers() {
  22. return [
  23. ['public'],
  24. ['protected'],
  25. ['private'],
  26. ];
  27. }
  28. }