public function testGenerate() { $implementation = new Implementation(); $expected = new ChoiceType(); $expected->addType('string', new StringType()); $expected->addType('boolean', new BooleanType()); $outline = $this->getExampleOutline(); $this->assertEquals($expected, $this->object->generate($outline, $implementation)); }
/** * {@inheritDoc} */ public function generate(TypeOutlineInterface $typeOutline, ImplementationInterface $implementation) { if (!$this->isAbleToGenerate($typeOutline)) { throw new UnableToGenerateTypeException('Invalid type outline', $typeOutline); } /** @var ChoiceTypeOutline $typeOutline */ $outlines = $typeOutline->getTypeOutlines(); if (count($outlines) < 2) { throw new UnableToGenerateTypeException('Choice type must use at least 2 types', $typeOutline); } $type = new ChoiceType(); foreach ($outlines as $typeOutline) { $type->addType($typeOutline->getName(), $this->linker->generateType($typeOutline, $implementation)); } return $type; }
public function testTypeNameCannotBeEmpty() { $this->cannotBeEmpty(); $this->object->addType('', new StringType()); }