3 namespace PhpParser\Node\Stmt;
5 class ClassTest extends \PHPUnit_Framework_TestCase
7 public function testIsAbstract() {
8 $class = new Class_('Foo', array('type' => Class_::MODIFIER_ABSTRACT));
9 $this->assertTrue($class->isAbstract());
11 $class = new Class_('Foo');
12 $this->assertFalse($class->isAbstract());
15 public function testIsFinal() {
16 $class = new Class_('Foo', array('type' => Class_::MODIFIER_FINAL));
17 $this->assertTrue($class->isFinal());
19 $class = new Class_('Foo');
20 $this->assertFalse($class->isFinal());
23 public function testGetMethods() {
25 new ClassMethod('foo'),
26 new ClassMethod('bar'),
27 new ClassMethod('fooBar'),
29 $class = new Class_('Foo', array(
31 new TraitUse(array()),
33 new ClassConst(array()),
35 new Property(0, array()),
40 $this->assertSame($methods, $class->getMethods());
43 public function testGetMethod() {
44 $methodConstruct = new ClassMethod('__CONSTRUCT');
45 $methodTest = new ClassMethod('test');
46 $class = new Class_('Foo', array(
48 new ClassConst(array()),
50 new Property(0, array()),
55 $this->assertSame($methodConstruct, $class->getMethod('__construct'));
56 $this->assertSame($methodTest, $class->getMethod('test'));
57 $this->assertNull($class->getMethod('nonExisting'));
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);