/**
  * Find the mapped table for a foreign related class
  * @test
  */
 public function anyToManyRelationToForeignClassBuildsCorrectRelationTableName()
 {
     $domainObjectName1 = 'DomainObject1';
     $description = 'My long domain object description';
     $relationName = 'Relation1';
     $className = '\\TYPO3\\CMS\\Extbase\\Domain\\Model\\FrontendUser';
     $input = array('name' => $domainObjectName1, 'objectsettings' => array('description' => $description, 'aggregateRoot' => TRUE, 'type' => 'Entity'), 'relationGroup' => array('relations' => array(0 => array('relationName' => $relationName, 'relationType' => 'zeroToMany', 'propertyIsExcludeField' => FALSE, 'foreignRelationClass' => $className))));
     $extbaseConfiguration = array('tableName' => 'fe_users');
     $this->configurationManager->expects($this->atLeastOnce())->method('getExtbaseClassConfiguration')->with($className)->will($this->returnValue($extbaseConfiguration));
     $domainObject1 = $this->objectSchemaBuilder->build($input);
     $relation = $domainObject1->getPropertyByName($relationName);
     $this->assertFalse($relation->getUseMMTable(), 'ZeroToMany Relation->getUseMMTable() returned TRUE.');
     $this->assertEquals('fe_users', $relation->getForeignDatabaseTableName());
 }
 /**
  *
  * @param array $extensionBuildConfiguration
  * @return \EBT\ExtensionBuilder\Domain\Model\Extension $extension
  */
 public function build(array $extensionBuildConfiguration)
 {
     /** @var $extension \EBT\ExtensionBuilder\Domain\Model\Extension */
     $extension = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('EBT\\ExtensionBuilder\\Domain\\Model\\Extension');
     $globalProperties = $extensionBuildConfiguration['properties'];
     if (!is_array($globalProperties)) {
         \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Error: Extension properties not submitted! ' . $extension->getOriginalExtensionKey(), 'builder', 3, $globalProperties);
         throw new \Exception('Extension properties not submitted!');
     }
     $this->setExtensionProperties($extension, $globalProperties);
     if (is_array($globalProperties['persons'])) {
         foreach ($globalProperties['persons'] as $personValues) {
             $person = $this->buildPerson($personValues);
             $extension->addPerson($person);
         }
     }
     if (is_array($globalProperties['plugins'])) {
         foreach ($globalProperties['plugins'] as $pluginValues) {
             $plugin = $this->buildPlugin($pluginValues);
             $extension->addPlugin($plugin);
         }
     }
     if (is_array($globalProperties['backendModules'])) {
         foreach ($globalProperties['backendModules'] as $backendModuleValues) {
             $backendModule = $this->buildBackendModule($backendModuleValues);
             $extension->addBackendModule($backendModule);
         }
     }
     // classes
     if (is_array($extensionBuildConfiguration['modules'])) {
         foreach ($extensionBuildConfiguration['modules'] as $singleModule) {
             $domainObject = $this->objectSchemaBuilder->build($singleModule['value']);
             if ($domainObject->isSubClass() && !$domainObject->isMappedToExistingTable()) {
                 // we try to get the table from Extbase configuration
                 $classSettings = $this->configurationManager->getExtbaseClassConfiguration($domainObject->getParentClass());
                 if (isset($classSettings['tableName'])) {
                     $tableName = $classSettings['tableName'];
                 } else {
                     // we use the default table name
                     $tableName = \EBT\ExtensionBuilder\Utility\Tools::parseTableNameFromClassName($domainObject->getParentClass());
                 }
                 if (!isset($GLOBALS['TCA'][$tableName])) {
                     throw new \Exception('Table definitions for table ' . $tableName . ' could not be loaded. You can only map to tables with existing TCA or extend classes of installed extensions!');
                 }
                 $domainObject->setMapToTable($tableName);
             }
             $extension->addDomainObject($domainObject);
         }
         // add child objects - needed to generate correct TCA for inheritance
         foreach ($extension->getDomainObjects() as $domainObject1) {
             foreach ($extension->getDomainObjects() as $domainObject2) {
                 if ($domainObject2->getParentClass() === $domainObject1->getFullQualifiedClassName()) {
                     $domainObject1->addChildObject($domainObject2);
                 }
             }
         }
     }
     // relations
     if (is_array($extensionBuildConfiguration['wires'])) {
         $this->setExtensionRelations($extensionBuildConfiguration, $extension);
     }
     return $extension;
 }