fa8aed8088e16530fb8a283ef3573361bc95e99d
[yaffs-website] / vendor / nikic / php-parser / test / PhpParser / Node / Stmt / ClassMethodTest.php
1 <?php
2
3 namespace PhpParser\Node\Stmt;
4
5 class ClassMethodTest extends \PHPUnit_Framework_TestCase
6 {
7     /**
8      * @dataProvider provideModifiers
9      */
10     public function testModifiers($modifier) {
11         $node = new ClassMethod('foo', array(
12             'type' => constant('PhpParser\Node\Stmt\Class_::MODIFIER_' . strtoupper($modifier))
13         ));
14
15         $this->assertTrue($node->{'is' . $modifier}());
16     }
17
18     public function testNoModifiers() {
19         $node = new ClassMethod('foo', array('type' => 0));
20
21         $this->assertTrue($node->isPublic());
22         $this->assertFalse($node->isProtected());
23         $this->assertFalse($node->isPrivate());
24         $this->assertFalse($node->isAbstract());
25         $this->assertFalse($node->isFinal());
26         $this->assertFalse($node->isStatic());
27     }
28
29     public function provideModifiers() {
30         return array(
31             array('public'),
32             array('protected'),
33             array('private'),
34             array('abstract'),
35             array('final'),
36             array('static'),
37         );
38     }
39
40     /**
41      * Checks that implicit public modifier detection for method is working
42      *
43      * @dataProvider implicitPublicModifiers
44      *
45      * @param integer $modifier Node type modifier
46      */
47     public function testImplicitPublic($modifier)
48     {
49         $node = new ClassMethod('foo', array(
50             'type' => constant('PhpParser\Node\Stmt\Class_::MODIFIER_' . strtoupper($modifier))
51         ));
52
53         $this->assertTrue($node->isPublic(), 'Node should be implicitly public');
54     }
55
56     public function implicitPublicModifiers() {
57         return array(
58             array('abstract'),
59             array('final'),
60             array('static'),
61         );
62     }
63 }