/** * @return PhpTrait */ private function createDummyTrait() { $trait = new PhpTrait('DummyTrait'); $trait->setNamespace('gossi\\codegen\\tests\\fixture'); $trait->setDescription('Dummy docblock'); $trait->setMethod(PhpMethod::create('foo')->setVisibility('public')); $trait->setProperty(PhpProperty::create('iAmHidden')->setVisibility('private')); $trait->addUseStatement('gossi\\codegen\\tests\\fixture\\VeryDummyTrait'); $trait->addTrait('VeryDummyTrait'); $trait->generateDocblock(); return $trait; }
public function testFromReflection() { $trait = new PhpTrait('DummyTrait'); $trait->setNamespace('gossi\\codegen\\tests\\fixture'); $trait->setDescription('Dummy docblock'); $trait->setMethod(PhpMethod::create('foo')->setVisibility('public')); $trait->setProperty(PhpProperty::create('iAmHidden')->setVisibility('private')); // @TODO: this alias is only a workaround $trait->addUseStatement('gossi\\codegen\\tests\\fixture\\VeryDummyTrait'); $trait->addTrait('VeryDummyTrait'); $trait->generateDocblock(); $this->assertEquals($trait, PhpTrait::fromReflection(new \ReflectionClass('gossi\\codegen\\tests\\fixture\\DummyTrait'))); }
public function testTrait() { $trait = new PhpTrait(); $trait->setDescription('my trait')->setLongDescription('this is my very long description')->setProperty($this->getProperty())->setMethod($this->getMethod()); $trait->generateDocblock(); $this->assertFalse($trait->getDocblock()->isEmpty()); $this->assertNotNull($trait->getProperty(self::PROP)->getDocblock()); $this->assertNotNull($trait->getMethod(self::METHOD)->getDocblock()); }