/** * @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 testEmptyTrait() { $trait = new PhpTrait(); $trait->generateDocblock(); $this->assertTrue($trait->getDocblock()->isEmpty()); }