private function registerPredefinedClassTypes(SchemaInterface $expectedSchema)
 {
     $classType = new ClassType('Exception', '\\Exception');
     $classType->addProperty(new PropertyDefinition('message', new StringType()));
     $cause = new PropertyDefinition('cause', $classType, true);
     $cause->setTargetPropertyName('previous');
     $classType->addProperty($cause);
     $expectedSchema->registerType('Exception', $classType);
 }
 public function testExceptionWhenParentClassOutlineWillBeTransformedToTypeThatIsNotInstanceOfAbstractClassType()
 {
     $msg = 'Parent type of class type must by an instance of class type';
     $this->setExpectedException('Wookieb\\ZorroDataSchema\\Exception\\UnableToGenerateTypeException', $msg);
     $parentClass = new ClassOutline('vacuumBadger');
     $outline = new ClassOutline('vacuum', array(), $parentClass);
     $this->schema->registerType('vacuumBadger', new BooleanType());
     $this->object->generate($outline, $this->implementation);
 }
Esempio n. 3
0
 /**
  * Performs build
  *
  * @param SchemaOutlineInterface $schemaOutline
  * @param ImplementationInterface $implementation
  * @param SchemaInterface $schema base schema used instead of default empty schema
  * @return SchemaInterface
  */
 public function build(SchemaOutlineInterface $schemaOutline, ImplementationInterface $implementation, SchemaInterface $schema = null)
 {
     $this->schema = $schema ?: ($this->schema ?: new Schema());
     foreach ($schemaOutline as $typeOutline) {
         /* @var \Wookieb\ZorroDataSchema\SchemaOutline\TypeOutline\TypeOutlineInterface $typeOutline */
         if ($this->schema->hasType($typeOutline->getName())) {
             continue;
         }
         $type = $this->generateType($typeOutline, $implementation);
         $this->schema->registerType($typeOutline->getName(), $type);
     }
     return $this->schema;
 }