InterfaceTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\Node\Stmt;
  3. use PhpParser\Node;
  4. use PhpParser\Node\Scalar\String_;
  5. class InterfaceTest extends \PHPUnit\Framework\TestCase
  6. {
  7. public function testGetMethods() {
  8. $methods = [
  9. new ClassMethod('foo'),
  10. new ClassMethod('bar'),
  11. ];
  12. $interface = new Interface_('Foo', [
  13. 'stmts' => [
  14. new Node\Stmt\ClassConst([new Node\Const_('C1', new Node\Scalar\String_('C1'))]),
  15. $methods[0],
  16. new Node\Stmt\ClassConst([new Node\Const_('C2', new Node\Scalar\String_('C2'))]),
  17. $methods[1],
  18. new Node\Stmt\ClassConst([new Node\Const_('C3', new Node\Scalar\String_('C3'))]),
  19. ]
  20. ]);
  21. $this->assertSame($methods, $interface->getMethods());
  22. }
  23. public function testGetConstants() {
  24. $constants = [
  25. new ClassConst([new \PhpParser\Node\Const_('foo', new String_('foo_value'))]),
  26. new ClassConst([new \PhpParser\Node\Const_('bar', new String_('bar_value'))]),
  27. ];
  28. $class = new Interface_('Foo', [
  29. 'stmts' => [
  30. new TraitUse([]),
  31. $constants[0],
  32. new ClassMethod('fooBar'),
  33. $constants[1],
  34. ]
  35. ]);
  36. $this->assertSame($constants, $class->getConstants());
  37. }
  38. }