コード例 #1
0
 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));
 }
コード例 #2
0
 /**
  * {@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;
 }
コード例 #3
0
 /**
  * @dataProvider exceptionWhenThereIsNoTypeAbleToExtractValueProvider
  */
 public function testExceptionWhenThereIsNoTypeAbleToExtractValue($value, $exceptionMessage = null)
 {
     if ($exceptionMessage) {
         $this->setExpectedException('Wookieb\\ZorroDataSchema\\Exception\\InvalidValueException', $exceptionMessage);
     }
     $this->object->extract($value);
 }