PropertyTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace PhpParser\Node\Stmt;
  3. class PropertyTest extends \PHPUnit_Framework_TestCase
  4. {
  5. /**
  6. * @dataProvider provideModifiers
  7. */
  8. public function testModifiers($modifier) {
  9. $node = new Property(
  10. constant('PhpParser\Node\Stmt\Class_::MODIFIER_' . strtoupper($modifier)),
  11. array() // invalid
  12. );
  13. $this->assertTrue($node->{'is' . $modifier}());
  14. }
  15. public function testNoModifiers() {
  16. $node = new Property(0, array());
  17. $this->assertTrue($node->isPublic());
  18. $this->assertFalse($node->isProtected());
  19. $this->assertFalse($node->isPrivate());
  20. $this->assertFalse($node->isStatic());
  21. }
  22. public function testStaticImplicitlyPublic() {
  23. $node = new Property(Class_::MODIFIER_STATIC, array());
  24. $this->assertTrue($node->isPublic());
  25. $this->assertFalse($node->isProtected());
  26. $this->assertFalse($node->isPrivate());
  27. $this->assertTrue($node->isStatic());
  28. }
  29. public function provideModifiers() {
  30. return array(
  31. array('public'),
  32. array('protected'),
  33. array('private'),
  34. array('static'),
  35. );
  36. }
  37. }