예제 #1
0
 /**
  * @test
  */
 public function domainObjectHasExpectedRelations()
 {
     $name = 'MyDomainObject';
     $description = 'My long domain object description';
     $className = '\\TYPO3\\CMS\\Extbase\\Domain\\Model\\FrontendUser';
     $input = array('name' => $name, 'objectsettings' => array('description' => $description, 'aggregateRoot' => true, 'type' => 'Entity'), 'relationGroup' => array('relations' => array(0 => array('relationName' => 'relation 1', 'relationType' => 'manyToMany', 'propertyIsExcludeField' => false, 'foreignRelationClass' => $className), 1 => array('relationName' => 'relation 2', 'relationType' => 'manyToMany', 'propertyIsExcludeField' => false, 'foreignRelationClass' => $className))));
     $expected = new \EBT\ExtensionBuilder\Domain\Model\DomainObject();
     $expected->setName($name);
     $expected->setDescription($description);
     $expected->setEntity(true);
     $expected->setAggregateRoot(true);
     $relation1 = new \EBT\ExtensionBuilder\Domain\Model\DomainObject\Relation\ManyToManyRelation('relation 1');
     $relation1->setForeignClassName($className);
     $relation1->setRelatedToExternalModel(true);
     $relation1->setExcludeField(false);
     $relation1->setForeignDatabaseTableName('fe_users');
     $relation2 = new \EBT\ExtensionBuilder\Domain\Model\DomainObject\Relation\ManyToManyRelation('relation 2');
     $relation2->setForeignClassName($className);
     $relation2->setRelatedToExternalModel(true);
     $relation2->setExcludeField(false);
     $relation2->setForeignDatabaseTableName('fe_users');
     $expected->addProperty($relation1);
     $expected->addProperty($relation2);
     $extbaseConfiguration = array('tableName' => 'fe_users');
     $this->configurationManager->expects($this->atLeastOnce())->method('getExtbaseClassConfiguration')->with($className)->will($this->returnValue($extbaseConfiguration));
     $actual = $this->objectSchemaBuilder->build($input);
     $this->assertEquals($actual, $expected, 'Domain Object not built correctly.');
 }
 /**
  * @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');
 }