/** * Tests the behavior of {@link PHP_Depend_Code_Function::findChildrenOfType()}. * * @return void */ public function testFindChildrenOfTypeReturnsExpectedResult() { $node1 = $this->getMock('PHP_Depend_Code_ASTNodeI', array(), array(), 'PHP_Depend_Code_ASTNodeI_' . md5(microtime())); $node1->expects($this->once())->method('findChildrenOfType')->will($this->returnValue(array())); $node2 = $this->getMock('PHP_Depend_Code_ASTNodeI', array(), array(), 'PHP_Depend_Code_ASTNodeI_' . md5(microtime())); $node2->expects($this->once())->method('findChildrenOfType')->will($this->returnValue(array())); $function = new PHP_Depend_Code_Function('Method'); $function->addChild($node1); $function->addChild($node2); $children = $function->findChildrenOfType(get_class($node2)); $this->assertSame(array($node2), $children); }
/** * Creates a ready to use function fixture. * * @param string $name Optional function name. * * @return PHP_Depend_Code_Function * @since 1.0.2 */ protected function createFunctionFixture($name = null) { $name = $name ? $name : get_class($this); $function = new PHP_Depend_Code_Function($name); $function->setSourceFile(new PHP_Depend_Code_File($GLOBALS['argv'][0])); $function->setCache(new PHP_Depend_Util_Cache_Driver_Memory()); $function->addChild(new PHP_Depend_Code_ASTFormalParameters()); return $function; }