/**
  * @test
  */
 public function conversionExtractsWholeExtensionMetadataWithRelations()
 {
     $input = array('modules' => array(0 => array('value' => array('name' => 'Blog', 'objectsettings' => array('description' => 'A blog object', 'aggregateRoot' => false, 'type' => 'Entity'), 'propertyGroup' => array('properties' => array(0 => array('propertyName' => 'name', 'propertyType' => 'String'), 1 => array('propertyName' => 'description', 'propertyType' => 'String'))), 'relationGroup' => array('relations' => array(0 => array('relationName' => 'posts', 'relationType' => 'zeroToMany', 'propertyIsExcludeField' => 1))))), 1 => array('value' => array('name' => 'Post', 'objectsettings' => array('description' => 'A blog post', 'aggregateRoot' => false, 'type' => 'Entity'), 'propertyGroup' => array('properties' => array()), 'relationGroup' => array('relations' => array(0 => array('relationName' => 'comments', 'relationType' => 'zeroToMany', 'propertyIsExcludeField' => 1))))), 2 => array('value' => array('name' => 'Comment', 'objectsettings' => array('description' => '', 'aggregateRoot' => false, 'type' => 'Entity'), 'propertyGroup' => array('properties' => array()), 'relationGroup' => array('relations' => array())))), 'properties' => array('description' => 'Some description', 'extensionKey' => $this->extensionKey, 'name' => 'My ext name', 'emConf' => array('state' => 'beta')), 'wires' => array(0 => array('tgt' => array('moduleId' => 1, 'terminal' => 'SOURCES'), 'src' => array('moduleId' => 0, 'terminal' => 'relationWire_0')), 1 => array('tgt' => array('moduleId' => 2, 'terminal' => 'SOURCES'), 'src' => array('moduleId' => 1, 'terminal' => 'relationWire_0'))));
     $extension = new \EBT\ExtensionBuilder\Domain\Model\Extension();
     $extension->setName('My ext name');
     $extension->setState(\EBT\ExtensionBuilder\Domain\Model\Extension::STATE_BETA);
     $extension->setExtensionKey($this->extensionKey);
     $extension->setDescription('Some description');
     $extension->setExtensionDir('');
     $blog = new \EBT\ExtensionBuilder\Domain\Model\DomainObject();
     $blog->setName('Blog');
     $blog->setDescription('A blog object');
     $blog->setEntity(true);
     $blog->setAggregateRoot(false);
     $property = new \EBT\ExtensionBuilder\Domain\Model\DomainObject\StringProperty('name');
     $blog->addProperty($property);
     $property = new \EBT\ExtensionBuilder\Domain\Model\DomainObject\StringProperty('description');
     $blog->addProperty($property);
     $extension->addDomainObject($blog);
     $post = new \EBT\ExtensionBuilder\Domain\Model\DomainObject();
     $post->setName('Post');
     $post->setDescription('A blog post');
     $post->setEntity(true);
     $post->setAggregateRoot(false);
     $extension->addDomainObject($post);
     $comment = new \EBT\ExtensionBuilder\Domain\Model\DomainObject();
     $comment->setName('Comment');
     $comment->setDescription('');
     $comment->setEntity(true);
     $comment->setAggregateRoot(false);
     $extension->addDomainObject($comment);
     $relation = new \EBT\ExtensionBuilder\Domain\Model\DomainObject\Relation\ZeroToManyRelation('posts');
     $relation->setForeignModel($post);
     $relation->setExcludeField(1);
     $blog->addProperty($relation);
     $relation = new \EBT\ExtensionBuilder\Domain\Model\DomainObject\Relation\ZeroToManyRelation('comments');
     $relation->setForeignModel($comment);
     $relation->setExcludeField(1);
     $post->addProperty($relation);
     $actualExtension = $this->extensionSchemaBuilder->build($input);
     self::assertEquals($extension->getDomainObjects(), $actualExtension->getDomainObjects(), 'The extensions differ');
 }
 /**
  * @test
  */
 public function anyToManyRelationHasExpectedProperties()
 {
     $domainObjectName1 = 'DomainObject1';
     $domainObjectName2 = 'DomainObject2';
     $description = 'My long domain object description';
     $relationName = 'Relation1';
     $input = array('name' => $domainObjectName1, 'objectsettings' => array('description' => $description, 'aggregateRoot' => TRUE, 'type' => 'Entity'), 'relationGroup' => array('relations' => array(0 => array('relationName' => $relationName, 'relationType' => 'zeroToMany', 'propertyIsExcludeField' => FALSE))));
     $domainObject1 = $this->objectSchemaBuilder->build($input);
     $input['name'] = $domainObjectName2;
     $domainObject2 = $this->objectSchemaBuilder->build($input);
     $dummyExtension = new \EBT\ExtensionBuilder\Domain\Model\Extension();
     $dummyExtension->setExtensionKey('dummy');
     $domainObject1->setExtension($dummyExtension);
     $domainObject2->setExtension($dummyExtension);
     $relation = $domainObject1->getPropertyByName($relationName);
     $relation->setForeignModel($domainObject2);
     $this->assertFalse($relation->getUseMMTable(), 'ZeroToMany Relation->getUseMMTable() returned TRUE.');
     $this->assertEquals('tx_dummy_domain_model_domainobject2', $relation->getForeignDatabaseTableName());
 }