/** * Tests the behavior of {@link \PDepend\Source\AST\ASTMethod::findChildrenOfType()}. * * @return void */ public function testFindChildrenOfTypeReturnsExpectedResult() { $node1 = $this->getMock('PDepend\\Source\\AST\\ASTNode', array(), array(), 'Class_' . __FUNCTION__ . '_' . md5(microtime())); $node1->expects($this->once())->method('findChildrenOfType')->will($this->returnValue(array())); $node2 = $this->getMock('PDepend\\Source\\AST\\ASTNode', array(), array(), 'Class_' . __FUNCTION__ . '_' . md5(microtime())); $node2->expects($this->once())->method('findChildrenOfType')->will($this->returnValue(array())); $method = new ASTMethod('Method'); $method->addChild($node1); $method->addChild($node2); $children = $method->findChildrenOfType(get_class($node2)); $this->assertSame(array($node2), $children); }
/** * Creates a ready to use method fixture. * * @param string $name Optional method name. * @return \PDepend\Source\AST\ASTMethod * @since 1.0.2 */ protected function createMethodFixture($name = null) { $name = $name ? $name : get_class($this); $method = new ASTMethod($name); $method->setCache(new MemoryCacheDriver()); $method->addChild(new ASTFormalParameters()); return $method; }