public function testReadWrite()
 {
     $author = new AuthorTag('gossi <*****@*****.**>');
     $this->assertEquals('gossi', $author->getName());
     $this->assertEquals('*****@*****.**', $author->getEmail());
     $this->assertEquals('@author gossi <*****@*****.**>', $author->toString());
     $author = new AuthorTag('lil-g');
     $this->assertEquals('lil-g', $author->getName());
     $this->assertEmpty($author->getEmail());
     $this->assertEquals('@author lil-g', $author->toString());
 }
Beispiel #2
0
 /**
  * Creates ClassWithComments
  * 
  * @return PhpClass
  */
 public static function createClassWithComments()
 {
     $class = PhpClass::create('gossi\\codegen\\tests\\fixtures\\ClassWithComments');
     $class->setDescription('A class with comments');
     $class->setLongDescription('Here is a super dooper long-description');
     $docblock = $class->getDocblock();
     $docblock->appendTag(AuthorTag::create('gossi'));
     $docblock->appendTag(SinceTag::create('0.2'));
     $class->setConstant(PhpConstant::create('FOO', 'bar')->setDescription('Best const ever')->setLongDescription('Aaaand we go along long')->setType('string')->setTypeDescription('baz'));
     $class->setProperty(PhpProperty::create('propper')->setDescription('best prop ever')->setLongDescription('Aaaand we go along long long')->setType('string')->setTypeDescription('Wer macht sauber?'));
     $class->setMethod(PhpMethod::create('setup')->setDescription('Short desc')->setLongDescription('Looong desc')->addParameter(PhpParameter::create('moo')->setType('boolean')->setTypeDescription('makes a cow'))->addParameter(PhpParameter::create('foo')->setType('foo', 'makes a fow'))->setType('boolean', 'true on success and false if it fails'));
     return $class;
 }
    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());
    }