/** * testBuilderCreatesExpectedIdentifierForMethod * * @return void */ public function testBuilderCreatesExpectedIdentifierForMethod() { $class = new ASTClass(__CLASS__); $class->setId('FooBar'); $method = new ASTMethod(__FUNCTION__); $method->setParent($class); $builder = new IdBuilder(); $this->assertRegExp('/^FooBar\\-[a-z0-9]{11}$/', $builder->forMethod($method)); }
/** * testIteratorReturnsSameClassOnlyOnce * * @return void */ public function testIteratorReturnsSameClassOnlyOnce() { $class1 = new ASTClass('c1'); $class1->setId(md5(23)); $class2 = new ASTClass('c2'); $class2->setId(md5(23)); $reference1 = $this->getMockBuilder('PDepend\\Source\\AST\\ASTSelfReference')->disableOriginalConstructor()->getMock(); $reference1->expects($this->once())->method('getType')->will($this->returnValue($class1)); $reference2 = $this->getMockBuilder('PDepend\\Source\\AST\\ASTSelfReference')->disableOriginalConstructor()->getMock(); $reference2->expects($this->once())->method('getType')->will($this->returnValue($class2)); $references = array($reference1, $reference2); $refs = new ASTClassOrInterfaceReferenceIterator($references); $types = array(); foreach ($refs as $type) { $types[] = $type->getId(); } $this->assertEquals(array($class1->getId()), $types); }