ClassConstTest.php 926 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\Node\Stmt;
  3. use PhpParser\Modifiers;
  4. class ClassConstTest extends \PHPUnit\Framework\TestCase {
  5. /**
  6. * @dataProvider provideModifiers
  7. */
  8. public function testModifiers($modifier): void {
  9. $node = new ClassConst(
  10. [], // invalid
  11. constant(Modifiers::class . '::' . strtoupper($modifier))
  12. );
  13. $this->assertTrue($node->{'is' . $modifier}());
  14. }
  15. public function testNoModifiers(): void {
  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 static function provideModifiers() {
  23. return [
  24. ['public'],
  25. ['protected'],
  26. ['private'],
  27. ['final'],
  28. ];
  29. }
  30. }