private function assertClassWithComments(PhpClass $class) { $docblock = $class->getDocblock(); $this->assertEquals($docblock->getShortDescription(), $class->getDescription()); $this->assertEquals($docblock->getLongDescription(), $class->getLongDescription()); $this->assertEquals('A class with comments', $docblock->getShortDescription()); $this->assertEquals('Here is a super dooper long-description', $docblock->getLongDescription()); $this->assertTrue($docblock->getTags('author')->size() > 0); $this->assertTrue($docblock->getTags('since')->size() > 0); $FOO = $class->getConstant('FOO'); $this->assertEquals('Best const ever', $FOO->getDescription()); $this->assertEquals('Aaaand we go along long', $FOO->getLongDescription()); $this->assertEquals('baz', $FOO->getTypeDescription()); $this->assertEquals('string', $FOO->getType()); $this->assertEquals('bar', $FOO->getValue()); $propper = $class->getProperty('propper'); $this->assertEquals('Best prop ever', $propper->getDescription()); $this->assertEquals('Aaaand we go along long long', $propper->getLongDescription()); $this->assertEquals('Wer macht sauber?', $propper->getTypeDescription()); $this->assertEquals('string', $propper->getType()); $this->assertEquals('Meister', $propper->getValue()); $setup = $class->getMethod('setup'); $this->assertEquals('Short desc', $setup->getDescription()); $this->assertEquals('Looong desc', $setup->getLongDescription()); $this->assertEquals('true on success and false if it fails', $setup->getTypeDescription()); $this->assertEquals('boolean', $setup->getType()); $moo = $setup->getParameter('moo'); $this->assertEquals('makes a cow', $moo->getTypeDescription()); $this->assertEquals('boolean', $moo->getType()); $foo = $setup->getParameter('foo'); $this->assertEquals('makes a fow', $foo->getTypeDescription()); $this->assertEquals('string', $foo->getType()); }
public function testClass() { $class = new PhpClass(); $class->setName('class-name')->setDescription('this is my class')->setLongDescription('this is my very long class')->setProperty($this->getProperty())->setMethod($this->getMethod())->setConstant($this->getConstant())->generateDocblock(); $this->assertFalse($class->getDocblock()->isEmpty()); $this->assertNotNull($class->getProperty(self::PROP)->getDocblock()); $this->assertNotNull($class->getMethod(self::METHOD)->getDocblock()); $this->assertNotNull($class->getConstant(self::CONSTANT)->getDocblock()); $docblock = $class->getDocblock(); $author = AuthorTag::create()->setName('gossi')->setEmail('*****@*****.**'); $docblock->appendTag($author); $this->assertTrue($docblock->hasTag('author')); $expected = '/** * this is my class * * this is my very long class * * @author gossi <*****@*****.**> */'; $this->assertEquals($expected, $docblock->toString()); }
protected function assertValueClass(PhpClass $class) { $values = $class->getMethod('values'); $this->isValueString($values->getParameter('paramString')); $this->isValueInteger($values->getParameter('paramInteger')); $this->isValueFloat($values->getParameter('paramFloat')); $this->isValueBool($values->getParameter('paramBool')); $this->isValueNull($values->getParameter('paramNull')); }
/** * @expectedException \InvalidArgumentException */ public function testGetMethodThrowsExceptionWhenConstantDoesNotExist() { $class = new PhpClass(); $class->getMethod('foo'); }