/** * testBuilderCreatesExpectedIdentifierForSecondFunction * * @return void */ public function testBuilderCreatesExpectedIdentifierForSecondFunction() { $compilationUnit = new ASTCompilationUnit(__FILE__); $compilationUnit->setId('FooBar'); $function1 = new ASTFunction(__FUNCTION__); $function1->setCompilationUnit($compilationUnit); $function2 = new ASTFunction(__CLASS__); $function2->setCompilationUnit($compilationUnit); $builder = new IdBuilder(); $builder->forFunction($function1); $this->assertRegExp('/^FooBar\\-[a-z0-9]{11}\\-00$/', $builder->forFunction($function2)); }
/** * Creates an abstract item instance. * * @return \PDepend\Source\AST\AbstractASTArtifact */ protected function createItem() { $function = new ASTFunction(__FUNCTION__); $function->setCompilationUnit(new ASTCompilationUnit(__FILE__)); $function->setContext($this->getMock('PDepend\\Source\\Builder\\BuilderContext')); return $function; }
/** * Creates a ready to use function fixture. * * @param string $name Optional function name. * @return \PDepend\Source\AST\ASTFunction * @since 1.0.2 */ protected function createFunctionFixture($name = null) { $name = $name ? $name : get_class($this); $function = new ASTFunction($name); $function->setCompilationUnit(new ASTCompilationUnit($GLOBALS['argv'][0])); $function->setCache(new MemoryCacheDriver()); $function->addChild(new ASTFormalParameters()); return $function; }