75d49e3a8a120d29fc0ea23ccee9ff5d80ab22bb
[yaffs-website] / vendor / nikic / php-parser / test / PhpParser / Node / Stmt / ClassTest.php
1 <?php
2
3 namespace PhpParser\Node\Stmt;
4
5 class ClassTest extends \PHPUnit_Framework_TestCase
6 {
7     public function testIsAbstract() {
8         $class = new Class_('Foo', array('type' => Class_::MODIFIER_ABSTRACT));
9         $this->assertTrue($class->isAbstract());
10
11         $class = new Class_('Foo');
12         $this->assertFalse($class->isAbstract());
13     }
14
15     public function testIsFinal() {
16         $class = new Class_('Foo', array('type' => Class_::MODIFIER_FINAL));
17         $this->assertTrue($class->isFinal());
18
19         $class = new Class_('Foo');
20         $this->assertFalse($class->isFinal());
21     }
22
23     public function testGetMethods() {
24         $methods = array(
25             new ClassMethod('foo'),
26             new ClassMethod('bar'),
27             new ClassMethod('fooBar'),
28         );
29         $class = new Class_('Foo', array(
30             'stmts' => array(
31                 new TraitUse(array()),
32                 $methods[0],
33                 new ClassConst(array()),
34                 $methods[1],
35                 new Property(0, array()),
36                 $methods[2],
37             )
38         ));
39
40         $this->assertSame($methods, $class->getMethods());
41     }
42
43     public function testGetMethod() {
44         $methodConstruct = new ClassMethod('__CONSTRUCT');
45         $methodTest = new ClassMethod('test');
46         $class = new Class_('Foo', array(
47             'stmts' => array(
48                 new ClassConst(array()),
49                 $methodConstruct,
50                 new Property(0, array()),
51                 $methodTest,
52             )
53         ));
54
55         $this->assertSame($methodConstruct, $class->getMethod('__construct'));
56         $this->assertSame($methodTest, $class->getMethod('test'));
57         $this->assertNull($class->getMethod('nonExisting'));
58     }
59
60     public function testDeprecatedTypeNode() {
61         $class = new Class_('Foo', array('type' => Class_::MODIFIER_ABSTRACT));
62         $this->assertTrue($class->isAbstract());
63         $this->assertSame(Class_::MODIFIER_ABSTRACT, $class->flags);
64         $this->assertSame(Class_::MODIFIER_ABSTRACT, $class->type);
65     }
66 }