public function testCannotUseOtherChoiceTypeOutline()
 {
     $outline = new ChoiceTypeOutline();
     $msg = 'Choice type cannot contain other Choice types';
     $this->setExpectedException('\\InvalidArgumentException', $msg);
     $this->object->addTypeOutline($outline);
 }
 public function testGenerate()
 {
     $expected = new ChoiceTypeOutline('string|boolean');
     $expected->addTypeOutline(new StringOutline('string'))->addTypeOutline(new BooleanOutline('boolean'));
     $result = $this->object->generate('string | boolean');
     $this->assertEquals($expected, $result);
 }
 public function testExceptionWhenAttemptToGenerateTypeWithLessThan2TypesUsed()
 {
     $msg = 'Choice type must use at least 2 types';
     $this->setExpectedException('Wookieb\\ZorroDataSchema\\Exception\\UnableToGenerateTypeException', $msg);
     $implementation = new Implementation();
     $outline = new ChoiceTypeOutline();
     $outline->addTypeOutline(new BooleanOutline('bool'));
     $this->object->generate($outline, $implementation);
 }
 /**
  * {@inheritDoc}
  */
 public function generate($name)
 {
     $typeNames = $this->extractTypeNames($name);
     if (count($typeNames) < 2) {
         $msg = 'Choice type "' . $name . '" defines only one type. At least 2 required';
         throw new UnableToGenerateTypeOutlineException($msg);
     }
     $name = implode('|', $typeNames);
     $outline = new ChoiceTypeOutline($name);
     foreach ($typeNames as $typeName) {
         $outline->addTypeOutline($this->schemaOutline->getTypeOutline($typeName));
     }
     return $outline;
 }