2012-07-07 16:08:37 +02:00
|
|
|
<?php
|
|
|
|
|
2014-02-06 14:44:16 +01:00
|
|
|
namespace PhpParser\Node\Stmt;
|
|
|
|
|
|
|
|
class ClassMethodTest 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 ClassMethod('foo', array(
|
|
|
|
'type' => constant('PhpParser\Node\Stmt\Class_::MODIFIER_' . strtoupper($modifier))
|
2012-07-07 16:08:37 +02:00
|
|
|
));
|
|
|
|
|
|
|
|
$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 ClassMethod('foo', array('type' => 0));
|
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->isAbstract());
|
|
|
|
$this->assertFalse($node->isFinal());
|
|
|
|
$this->assertFalse($node->isStatic());
|
2012-07-07 16:08:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function provideModifiers() {
|
|
|
|
return array(
|
|
|
|
array('public'),
|
|
|
|
array('protected'),
|
|
|
|
array('private'),
|
|
|
|
array('abstract'),
|
|
|
|
array('final'),
|
|
|
|
array('static'),
|
|
|
|
);
|
|
|
|
}
|
2014-11-13 20:18:49 +01:00
|
|
|
}
|