ClassTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. class PHPParser_Tests_Node_Stmt_ClassTest extends PHPUnit_Framework_TestCase
  3. {
  4. public function testIsAbstract() {
  5. $class = new PHPParser_Node_Stmt_Class('Foo', array('type' => PHPParser_Node_Stmt_Class::MODIFIER_ABSTRACT));
  6. $this->assertTrue($class->isAbstract());
  7. $class = new PHPParser_Node_Stmt_Class('Foo');
  8. $this->assertFalse($class->isAbstract());
  9. }
  10. public function testIsFinal() {
  11. $class = new PHPParser_Node_Stmt_Class('Foo', array('type' => PHPParser_Node_Stmt_Class::MODIFIER_FINAL));
  12. $this->assertTrue($class->isFinal());
  13. $class = new PHPParser_Node_Stmt_Class('Foo');
  14. $this->assertFalse($class->isFinal());
  15. }
  16. public function testGetMethods() {
  17. $methods = array(
  18. new PHPParser_Node_Stmt_ClassMethod('foo'),
  19. new PHPParser_Node_Stmt_ClassMethod('bar'),
  20. new PHPParser_Node_Stmt_ClassMethod('fooBar'),
  21. );
  22. $class = new PHPParser_Node_Stmt_Class('Foo', array(
  23. 'stmts' => array(
  24. new PHPParser_Node_Stmt_TraitUse(array()),
  25. $methods[0],
  26. new PHPParser_Node_Stmt_Const(array()),
  27. $methods[1],
  28. new PHPParser_Node_Stmt_Property(0, array()),
  29. $methods[2],
  30. )
  31. ));
  32. $this->assertEquals($methods, $class->getMethods());
  33. }
  34. }