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}());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider provideModifiers
|
|
|
|
*/
|
|
|
|
public function testNoModifiers($modifier) {
|
2014-02-06 14:44:16 +01:00
|
|
|
$node = new ClassMethod('foo', array('type' => 0));
|
2012-07-07 16:08:37 +02:00
|
|
|
|
|
|
|
$this->assertFalse($node->{'is' . $modifier}());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function provideModifiers() {
|
|
|
|
return array(
|
|
|
|
array('public'),
|
|
|
|
array('protected'),
|
|
|
|
array('private'),
|
|
|
|
array('abstract'),
|
|
|
|
array('final'),
|
|
|
|
array('static'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|