Mercurial > hg > isophonics-drupal-site
comparison vendor/nikic/php-parser/test/PhpParser/Node/Stmt/ClassMethodTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 5fb285c0d0e3 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
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 } |