2012-07-07 16:08:37 +02:00
|
|
|
<?php
|
|
|
|
|
2014-02-06 14:44:16 +01:00
|
|
|
namespace PhpParser\Node\Stmt;
|
|
|
|
|
|
|
|
class PropertyTest extends \PHPUnit_Framework_TestCase
|
2012-07-07 16:08:37 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @dataProvider provideModifiers
|
|
|
|
*/
|
|
|
|
public function testModifiers($modifier) {
|
2014-02-06 14:44:16 +01:00
|
|
|
$node = new Property(
|
|
|
|
constant('PhpParser\Node\Stmt\Class_::MODIFIER_' . strtoupper($modifier)),
|
2012-07-07 16:08:37 +02:00
|
|
|
array() // invalid
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertTrue($node->{'is' . $modifier}());
|
|
|
|
}
|
|
|
|
|
2014-11-13 20:18:49 +01:00
|
|
|
public function testNoModifiers() {
|
2014-02-06 14:44:16 +01:00
|
|
|
$node = new Property(0, array());
|
2012-07-07 16:08:37 +02:00
|
|
|
|
2014-11-13 20:18:49 +01:00
|
|
|
$this->assertTrue($node->isPublic());
|
|
|
|
$this->assertFalse($node->isProtected());
|
|
|
|
$this->assertFalse($node->isPrivate());
|
|
|
|
$this->assertFalse($node->isStatic());
|
2012-07-07 16:08:37 +02:00
|
|
|
}
|
|
|
|
|
2015-07-05 20:15:02 +02:00
|
|
|
public function testStaticImplicitlyPublic() {
|
|
|
|
$node = new Property(Class_::MODIFIER_STATIC, array());
|
|
|
|
$this->assertTrue($node->isPublic());
|
|
|
|
$this->assertFalse($node->isProtected());
|
|
|
|
$this->assertFalse($node->isPrivate());
|
|
|
|
$this->assertTrue($node->isStatic());
|
|
|
|
}
|
|
|
|
|
2012-07-07 16:08:37 +02:00
|
|
|
public function provideModifiers() {
|
|
|
|
return array(
|
|
|
|
array('public'),
|
|
|
|
array('protected'),
|
|
|
|
array('private'),
|
|
|
|
array('static'),
|
|
|
|
);
|
|
|
|
}
|
2014-11-13 20:18:49 +01:00
|
|
|
}
|