[TASK] Extract datahandling framework to testing-framework 28/52728/9
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 20 May 2017 16:36:34 +0000 (18:36 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 22 May 2017 11:19:56 +0000 (13:19 +0200)
Ext:core comes with a little testing framework for functional tests,
that is pretty useful for all kind of DataHandler related tests. Those
classes are better located in the testing-framework package to be
available.

Change-Id: I429e801b7318fda3a96acb4f5f63bb75050fb3e3
Resolves: #81154
Releases: master, 8.7
Reviewed-on: https://review.typo3.org/52728
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Tests/Functional/DataHandling/AbstractDataHandlerActionTestCase.php
typo3/sysext/core/Tests/Functional/DataHandling/Framework/ActionService.php [deleted file]
typo3/sysext/core/Tests/Functional/DataHandling/Framework/DataSet.php [deleted file]

index 728cc78..3755c51 100644 (file)
@@ -14,13 +14,20 @@ namespace TYPO3\CMS\Core\Tests\Functional\DataHandling;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\TestingFramework\Core\Functional\Framework\Constraint\RequestSection\DoesNotHaveRecordConstraint;
+use TYPO3\TestingFramework\Core\Functional\Framework\Constraint\RequestSection\HasRecordConstraint;
+use TYPO3\TestingFramework\Core\Functional\Framework\Constraint\RequestSection\StructureDoesNotHaveRecordConstraint;
+use TYPO3\TestingFramework\Core\Functional\Framework\Constraint\RequestSection\StructureHasRecordConstraint;
+use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\ActionService;
+use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
 
 /**
  * Functional test for the DataHandler
  */
-abstract class AbstractDataHandlerActionTestCase extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
+abstract class AbstractDataHandlerActionTestCase extends FunctionalTestCase
 {
     const VALUE_BackendUserId = 1;
 
@@ -62,7 +69,7 @@ abstract class AbstractDataHandlerActionTestCase extends \TYPO3\TestingFramework
     protected $recordIds = [];
 
     /**
-     * @var \TYPO3\CMS\Core\Tests\Functional\DataHandling\Framework\ActionService
+     * @var ActionService
      */
     protected $actionService;
 
@@ -80,7 +87,7 @@ abstract class AbstractDataHandlerActionTestCase extends \TYPO3\TestingFramework
         $this->backendUser->workspace = 0;
 
         $this->actionService = $this->getActionService();
-        \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeLanguageObject();
+        Bootstrap::getInstance()->initializeLanguageObject();
     }
 
     protected function tearDown()
@@ -92,12 +99,12 @@ abstract class AbstractDataHandlerActionTestCase extends \TYPO3\TestingFramework
     }
 
     /**
-     * @return \TYPO3\CMS\Core\Tests\Functional\DataHandling\Framework\ActionService
+     * @return ActionService
      */
     protected function getActionService()
     {
         return GeneralUtility::makeInstance(
-            \TYPO3\CMS\Core\Tests\Functional\DataHandling\Framework\ActionService::class
+            ActionService::class
         );
     }
 
@@ -156,34 +163,34 @@ abstract class AbstractDataHandlerActionTestCase extends \TYPO3\TestingFramework
     }
 
     /**
-     * @return \TYPO3\TestingFramework\Core\Functional\Framework\Constraint\RequestSection\HasRecordConstraint
+     * @return HasRecordConstraint
      */
     protected function getRequestSectionHasRecordConstraint()
     {
-        return new \TYPO3\TestingFramework\Core\Functional\Framework\Constraint\RequestSection\HasRecordConstraint();
+        return new HasRecordConstraint();
     }
 
     /**
-     * @return \TYPO3\TestingFramework\Core\Functional\Framework\Constraint\RequestSection\DoesNotHaveRecordConstraint
+     * @return DoesNotHaveRecordConstraint
      */
     protected function getRequestSectionDoesNotHaveRecordConstraint()
     {
-        return new \TYPO3\TestingFramework\Core\Functional\Framework\Constraint\RequestSection\DoesNotHaveRecordConstraint();
+        return new DoesNotHaveRecordConstraint();
     }
 
     /**
-     * @return \TYPO3\TestingFramework\Core\Functional\Framework\Constraint\RequestSection\StructureHasRecordConstraint
+     * @return StructureHasRecordConstraint
      */
     protected function getRequestSectionStructureHasRecordConstraint()
     {
-        return new \TYPO3\TestingFramework\Core\Functional\Framework\Constraint\RequestSection\StructureHasRecordConstraint();
+        return new StructureHasRecordConstraint();
     }
 
     /**
-     * @return \TYPO3\TestingFramework\Core\Functional\Framework\Constraint\RequestSection\StructureDoesNotHaveRecordConstraint
+     * @return StructureDoesNotHaveRecordConstraint
      */
     protected function getRequestSectionStructureDoesNotHaveRecordConstraint()
     {
-        return new \TYPO3\TestingFramework\Core\Functional\Framework\Constraint\RequestSection\StructureDoesNotHaveRecordConstraint();
+        return new StructureDoesNotHaveRecordConstraint();
     }
 }
diff --git a/typo3/sysext/core/Tests/Functional/DataHandling/Framework/ActionService.php b/typo3/sysext/core/Tests/Functional/DataHandling/Framework/ActionService.php
deleted file mode 100644 (file)
index e5cf2ba..0000000
+++ /dev/null
@@ -1,523 +0,0 @@
-<?php
-namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\Framework;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Core\Database\ConnectionPool;
-use TYPO3\CMS\Core\DataHandling\DataHandler;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
-
-/**
- * DataHandler Actions
- */
-class ActionService
-{
-    /**
-     * @var DataHandler
-     */
-    protected $dataHandler;
-
-    /**
-     * @return DataHandler
-     */
-    public function getDataHandler()
-    {
-        return $this->dataHandler;
-    }
-
-    /**
-     * @param string $tableName
-     * @param int $pageId
-     * @param array $recordData
-     * @return array
-     */
-    public function createNewRecord($tableName, $pageId, array $recordData)
-    {
-        return $this->createNewRecords($pageId, [$tableName => $recordData]);
-    }
-
-    /**
-     * @param int $pageId
-     * @param array $tableRecordData
-     * @return array
-     */
-    public function createNewRecords($pageId, array $tableRecordData)
-    {
-        $dataMap = [];
-        $newTableIds = [];
-        $currentUid = null;
-        $previousTableName = null;
-        $previousUid = null;
-        foreach ($tableRecordData as $tableName => $recordData) {
-            $recordData = $this->resolvePreviousUid($recordData, $currentUid);
-            if (!isset($recordData['pid'])) {
-                $recordData['pid'] = $pageId;
-            }
-            $currentUid = StringUtility::getUniqueId('NEW');
-            $newTableIds[$tableName][] = $currentUid;
-            $dataMap[$tableName][$currentUid] = $recordData;
-            if ($previousTableName !== null && $previousUid !== null) {
-                $dataMap[$previousTableName][$previousUid] = $this->resolveNextUid(
-                    $dataMap[$previousTableName][$previousUid],
-                    $currentUid
-                );
-            }
-            $previousTableName = $tableName;
-            $previousUid = $currentUid;
-        }
-        $this->createDataHandler();
-        $this->dataHandler->start($dataMap, []);
-        $this->dataHandler->process_datamap();
-
-        foreach ($newTableIds as $tableName => &$ids) {
-            foreach ($ids as &$id) {
-                if (!empty($this->dataHandler->substNEWwithIDs[$id])) {
-                    $id = $this->dataHandler->substNEWwithIDs[$id];
-                }
-            }
-        }
-
-        return $newTableIds;
-    }
-
-    /**
-     * @param string $tableName
-     * @param int $uid
-     * @param array $recordData
-     * @param NULL|array $deleteTableRecordIds
-     */
-    public function modifyRecord($tableName, $uid, array $recordData, array $deleteTableRecordIds = null)
-    {
-        $dataMap = [
-            $tableName => [
-                $uid => $recordData,
-            ],
-        ];
-        $commandMap = [];
-        if (!empty($deleteTableRecordIds)) {
-            foreach ($deleteTableRecordIds as $tableName => $recordIds) {
-                foreach ($recordIds as $recordId) {
-                    $commandMap[$tableName][$recordId]['delete'] = true;
-                }
-            }
-        }
-        $this->createDataHandler();
-        $this->dataHandler->start($dataMap, $commandMap);
-        $this->dataHandler->process_datamap();
-        if (!empty($commandMap)) {
-            $this->dataHandler->process_cmdmap();
-        }
-    }
-
-    /**
-     * @param int $pageId
-     * @param array $tableRecordData
-     */
-    public function modifyRecords($pageId, array $tableRecordData)
-    {
-        $dataMap = [];
-        $currentUid = null;
-        $previousTableName = null;
-        $previousUid = null;
-        foreach ($tableRecordData as $tableName => $recordData) {
-            if (empty($recordData['uid'])) {
-                continue;
-            }
-            $recordData = $this->resolvePreviousUid($recordData, $currentUid);
-            $currentUid = $recordData['uid'];
-            if ($recordData['uid'] === '__NEW') {
-                $currentUid = StringUtility::getUniqueId('NEW');
-            }
-            if (strpos($currentUid, 'NEW') === 0) {
-                $recordData['pid'] = $pageId;
-            }
-            unset($recordData['uid']);
-            $dataMap[$tableName][$currentUid] = $recordData;
-            if ($previousTableName !== null && $previousUid !== null) {
-                $dataMap[$previousTableName][$previousUid] = $this->resolveNextUid(
-                    $dataMap[$previousTableName][$previousUid],
-                    $currentUid
-                );
-            }
-            $previousTableName = $tableName;
-            $previousUid = $currentUid;
-        }
-        $this->createDataHandler();
-        $this->dataHandler->start($dataMap, []);
-        $this->dataHandler->process_datamap();
-    }
-
-    /**
-     * @param string $tableName
-     * @param int $uid
-     * @return array
-     */
-    public function deleteRecord($tableName, $uid)
-    {
-        return $this->deleteRecords(
-            [
-                $tableName => [$uid],
-            ]
-        );
-    }
-
-    /**
-     * @param array $tableRecordIds
-     * @return array
-     */
-    public function deleteRecords(array $tableRecordIds)
-    {
-        $commandMap = [];
-        foreach ($tableRecordIds as $tableName => $ids) {
-            foreach ($ids as $uid) {
-                $commandMap[$tableName][$uid] = [
-                    'delete' => true,
-                ];
-            }
-        }
-        $this->createDataHandler();
-        $this->dataHandler->start([], $commandMap);
-        $this->dataHandler->process_cmdmap();
-        // Deleting workspace records is actually a copy(!)
-        return $this->dataHandler->copyMappingArray;
-    }
-
-    /**
-     * @param string $tableName
-     * @param int $uid
-     */
-    public function clearWorkspaceRecord($tableName, $uid)
-    {
-        $this->clearWorkspaceRecords(
-            [
-                $tableName => [$uid],
-            ]
-        );
-    }
-
-    /**
-     * @param array $tableRecordIds
-     */
-    public function clearWorkspaceRecords(array $tableRecordIds)
-    {
-        $commandMap = [];
-        foreach ($tableRecordIds as $tableName => $ids) {
-            foreach ($ids as $uid) {
-                $commandMap[$tableName][$uid] = [
-                    'version' => [
-                        'action' => 'clearWSID',
-                    ]
-                ];
-            }
-        }
-        $this->createDataHandler();
-        $this->dataHandler->start([], $commandMap);
-        $this->dataHandler->process_cmdmap();
-    }
-
-    /**
-     * @param string $tableName
-     * @param int $uid
-     * @param int $pageId
-     * @param NULL|array $recordData
-     * @return array
-     */
-    public function copyRecord($tableName, $uid, $pageId, array $recordData = null)
-    {
-        $commandMap = [
-            $tableName => [
-                $uid => [
-                    'copy' => $pageId,
-                ],
-            ],
-        ];
-        if ($recordData !== null) {
-            $commandMap[$tableName][$uid]['copy'] = [
-                'action' => 'paste',
-                'target' => $pageId,
-                'update' => $recordData,
-            ];
-        }
-        $this->createDataHandler();
-        $this->dataHandler->start([], $commandMap);
-        $this->dataHandler->process_cmdmap();
-        return $this->dataHandler->copyMappingArray;
-    }
-
-    /**
-     * @param string $tableName
-     * @param int $uid
-     * @param int $pageId
-     * @param NULL|array $recordData
-     * @return array
-     */
-    public function moveRecord($tableName, $uid, $pageId, array $recordData = null)
-    {
-        $commandMap = [
-            $tableName => [
-                $uid => [
-                    'move' => $pageId,
-                ],
-            ],
-        ];
-        if ($recordData !== null) {
-            $commandMap[$tableName][$uid]['move'] = [
-                'action' => 'paste',
-                'target' => $pageId,
-                'update' => $recordData,
-            ];
-        }
-        $this->createDataHandler();
-        $this->dataHandler->start([], $commandMap);
-        $this->dataHandler->process_cmdmap();
-        return $this->dataHandler->copyMappingArray;
-    }
-
-    /**
-     * @param string $tableName
-     * @param int $uid
-     * @param int $languageId
-     * @return array
-     */
-    public function localizeRecord($tableName, $uid, $languageId)
-    {
-        $commandMap = [
-            $tableName => [
-                $uid => [
-                    'localize' => $languageId,
-                ],
-            ],
-        ];
-        $this->createDataHandler();
-        $this->dataHandler->start([], $commandMap);
-        $this->dataHandler->process_cmdmap();
-        return $this->dataHandler->copyMappingArray;
-    }
-
-    /**
-     * @param string $tableName
-     * @param int $uid
-     * @param int $languageId
-     * @return array
-     */
-    public function copyRecordToLanguage($tableName, $uid, $languageId)
-    {
-        $commandMap = [
-            $tableName => [
-                $uid => [
-                    'copyToLanguage' => $languageId,
-                ],
-            ],
-        ];
-        $this->createDataHandler();
-        $this->dataHandler->start([], $commandMap);
-        $this->dataHandler->process_cmdmap();
-        return $this->dataHandler->copyMappingArray;
-    }
-
-    /**
-     * @param string $tableName
-     * @param int $uid
-     * @param string $fieldName
-     * @param array $referenceIds
-     */
-    public function modifyReferences($tableName, $uid, $fieldName, array $referenceIds)
-    {
-        $dataMap = [
-            $tableName => [
-                $uid => [
-                    $fieldName => implode(',', $referenceIds),
-                ],
-            ]
-        ];
-        $this->createDataHandler();
-        $this->dataHandler->start($dataMap, []);
-        $this->dataHandler->process_datamap();
-    }
-
-    /**
-     * @param string $tableName
-     * @param int $liveUid
-     * @param bool $throwException
-     */
-    public function publishRecord($tableName, $liveUid, $throwException = true)
-    {
-        $this->publishRecords([$tableName => [$liveUid]], $throwException);
-    }
-
-    /**
-     * @param array $tableLiveUids
-     * @param bool $throwException
-     * @throws \TYPO3\TestingFramework\Core\Exception
-     */
-    public function publishRecords(array $tableLiveUids, $throwException = true)
-    {
-        $commandMap = [];
-        foreach ($tableLiveUids as $tableName => $liveUids) {
-            foreach ($liveUids as $liveUid) {
-                $versionedUid = $this->getVersionedId($tableName, $liveUid);
-                if (empty($versionedUid)) {
-                    if ($throwException) {
-                        throw new \TYPO3\TestingFramework\Core\Exception('Versioned UID could not be determined', 1476049592);
-                    } else {
-                        continue;
-                    }
-                }
-
-                $commandMap[$tableName][$liveUid] = [
-                    'version' => [
-                        'action' => 'swap',
-                        'swapWith' => $versionedUid,
-                        'notificationAlternativeRecipients' => [],
-                    ],
-                ];
-            }
-        }
-        $this->createDataHandler();
-        $this->dataHandler->start([], $commandMap);
-        $this->dataHandler->process_cmdmap();
-    }
-
-    /**
-     * @param int $workspaceId
-     */
-    public function publishWorkspace($workspaceId)
-    {
-        $commandMap = $this->getWorkspaceService()->getCmdArrayForPublishWS($workspaceId, false);
-        $this->createDataHandler();
-        $this->dataHandler->start([], $commandMap);
-        $this->dataHandler->process_cmdmap();
-    }
-
-    /**
-     * @param int $workspaceId
-     */
-    public function swapWorkspace($workspaceId)
-    {
-        $commandMap = $this->getWorkspaceService()->getCmdArrayForPublishWS($workspaceId, true);
-        $this->createDataHandler();
-        $this->dataHandler->start([], $commandMap);
-        $this->dataHandler->process_cmdmap();
-    }
-
-    /**
-     * @param array $recordData
-     * @param NULL|string|int $previousUid
-     * @return array
-     */
-    protected function resolvePreviousUid(array $recordData, $previousUid)
-    {
-        if ($previousUid === null) {
-            return $recordData;
-        }
-        foreach ($recordData as $fieldName => $fieldValue) {
-            if (strpos($fieldValue, '__previousUid') === false) {
-                continue;
-            }
-            $recordData[$fieldName] = str_replace('__previousUid', $previousUid, $fieldValue);
-        }
-        return $recordData;
-    }
-
-    /**
-     * @param array $recordData
-     * @param NULL|string|int $nextUid
-     * @return array
-     */
-    protected function resolveNextUid(array $recordData, $nextUid)
-    {
-        if ($nextUid === null) {
-            return $recordData;
-        }
-        foreach ($recordData as $fieldName => $fieldValue) {
-            if (strpos($fieldValue, '__nextUid') === false) {
-                continue;
-            }
-            $recordData[$fieldName] = str_replace('__nextUid', $nextUid, $fieldValue);
-        }
-        return $recordData;
-    }
-
-    /**
-     * @param string $tableName
-     * @param int $liveUid
-     * @return NULL|int
-     */
-    protected function getVersionedId($tableName, $liveUid)
-    {
-        $versionedId = null;
-        $liveUid = (int)$liveUid;
-        $workspaceId = (int)$this->getBackendUser()->workspace;
-
-        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
-            ->getQueryBuilderForTable($tableName);
-        $queryBuilder->getRestrictions()->removeAll();
-        $statement = $queryBuilder
-            ->select('uid')
-            ->from($tableName)
-            ->where(
-                $queryBuilder->expr()->eq(
-                    'pid',
-                    $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)
-                ),
-                $queryBuilder->expr()->eq(
-                    't3ver_oid',
-                    $queryBuilder->createNamedParameter($liveUid, \PDO::PARAM_INT)
-                ),
-                $queryBuilder->expr()->eq(
-                    't3ver_wsid',
-                    $queryBuilder->createNamedParameter($workspaceId, \PDO::PARAM_INT)
-                )
-            )
-            ->execute();
-
-        $row = $statement->fetch();
-        if (!empty($row['uid'])) {
-            $versionedId = (int)$row['uid'];
-        }
-        return $versionedId;
-    }
-
-    /**
-     * @return DataHandler
-     */
-    protected function createDataHandler()
-    {
-        $this->dataHandler = GeneralUtility::makeInstance(DataHandler::class);
-        $backendUser = $this->getBackendUser();
-        if (isset($backendUser->uc['copyLevels'])) {
-            $this->dataHandler->copyTree = $backendUser->uc['copyLevels'];
-        }
-        return $this->dataHandler;
-    }
-
-    /**
-     * @return \TYPO3\CMS\Workspaces\Service\WorkspaceService
-     */
-    protected function getWorkspaceService()
-    {
-        return GeneralUtility::makeInstance(
-            \TYPO3\CMS\Workspaces\Service\WorkspaceService::class
-        );
-    }
-
-    /**
-     * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
-     */
-    protected function getBackendUser()
-    {
-        return $GLOBALS['BE_USER'];
-    }
-}
diff --git a/typo3/sysext/core/Tests/Functional/DataHandling/Framework/DataSet.php b/typo3/sysext/core/Tests/Functional/DataHandling/Framework/DataSet.php
deleted file mode 100644 (file)
index c49eb9a..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-<?php
-namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\Framework;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-
-/**
- * DataHandler DataSet
- */
-class DataSet
-{
-    /**
-     * @var array
-     */
-    protected $data;
-
-    /**
-     * @param string $fileName
-     * @param bool $applyDefaultValues
-     * @return DataSet
-     */
-    public static function read($fileName, $applyDefaultValues = false)
-    {
-        $data = self::parseData(self::readData($fileName));
-
-        if ($applyDefaultValues) {
-            $data = self::applyDefaultValues($data);
-        }
-
-        return GeneralUtility::makeInstance(
-            \TYPO3\CMS\Core\Tests\Functional\DataHandling\Framework\DataSet::class,
-            $data
-        );
-    }
-
-    /**
-     * @param string $fileName
-     * @return array
-     * @throws \RuntimeException
-     */
-    protected static function readData($fileName)
-    {
-        if (!file_exists($fileName)) {
-            throw new \RuntimeException('File "' . $fileName . '" does not exist', 1476049619);
-        }
-
-        $rawData = [];
-        $fileHandle = fopen($fileName, 'r');
-        while (($values = fgetcsv($fileHandle, 0)) !== false) {
-            $rawData[] = $values;
-        }
-        fclose($fileHandle);
-        return $rawData;
-    }
-
-    /**
-     * Parses CSV data.
-     *
-     * Special values are:
-     * + "\NULL" to treat as NULL value
-     * + "\*" to ignore value during comparison
-     *
-     * @param array $rawData
-     * @return array
-     */
-    protected static function parseData(array $rawData)
-    {
-        $data = [];
-        $tableName = null;
-        $fieldCount = null;
-        $idIndex = null;
-        foreach ($rawData as $values) {
-            if (!empty($values[0])) {
-                // Skip comment lines, starting with "#"
-                if ($values[0]{0} === '#') {
-                    continue;
-                }
-                $tableName = $values[0];
-                $fieldCount = null;
-                $idIndex = null;
-                if (!isset($data[$tableName])) {
-                    $data[$tableName] = [];
-                }
-            } elseif (implode('', $values) === '') {
-                $tableName = null;
-                $fieldCount = null;
-                $idIndex = null;
-            } elseif ($tableName !== null && !empty($values[1])) {
-                array_shift($values);
-                if (!isset($data[$tableName]['fields'])) {
-                    $data[$tableName]['fields'] = [];
-                    foreach ($values as $value) {
-                        if (empty($value)) {
-                            continue;
-                        }
-                        $data[$tableName]['fields'][] = $value;
-                        $fieldCount = count($data[$tableName]['fields']);
-                    }
-                    if (in_array('uid', $values)) {
-                        $idIndex = array_search('uid', $values);
-                        $data[$tableName]['idIndex'] = $idIndex;
-                    }
-                } else {
-                    if (!isset($data[$tableName]['elements'])) {
-                        $data[$tableName]['elements'] = [];
-                    }
-                    $values = array_slice($values, 0, $fieldCount);
-                    foreach ($values as &$value) {
-                        if ($value === '\\NULL') {
-                            $value = null;
-                        }
-                    }
-                    unset($value);
-                    $element = array_combine($data[$tableName]['fields'], $values);
-                    if ($idIndex !== null) {
-                        $data[$tableName]['elements'][$values[$idIndex]] = $element;
-                    } else {
-                        $data[$tableName]['elements'][] = $element;
-                    }
-                }
-            }
-        }
-        return $data;
-    }
-
-    /**
-     * Applies TCA default values to missing fields on the imported scenario data-set.
-     * This is basically required for running the functional tests in a SQL strict mode environment.
-     *
-     * @param array $data
-     * @return array
-     */
-    protected static function applyDefaultValues(array $data)
-    {
-        foreach ($data as $tableName => $sections) {
-            if (empty($GLOBALS['TCA'][$tableName]['columns'])) {
-                continue;
-            }
-
-            $fields = $sections['fields'];
-
-            foreach ($GLOBALS['TCA'][$tableName]['columns'] as $tcaFieldName => $tcaFieldConfiguration) {
-                // Skip if field was already imported
-                if (in_array($tcaFieldName, $fields)) {
-                    continue;
-                }
-                // Skip if field is an enable-column (it's expected that those fields have proper DBMS defaults)
-                if (!empty($GLOBALS['TCA'][$tableName]['ctrl']['enablecolumns']) && in_array($tcaFieldName, $GLOBALS['TCA'][$tableName]['ctrl']['enablecolumns'])) {
-                    continue;
-                }
-                // Skip if no default value is defined in the accordant TCA definition (NULL values might occur as well)
-                if (empty($tcaFieldConfiguration['config']) || !array_key_exists('default', $tcaFieldConfiguration['config'])) {
-                    continue;
-                }
-
-                $data[$tableName]['fields'][] = $tcaFieldName;
-                foreach ($data[$tableName]['elements'] as &$element) {
-                    $element[$tcaFieldName] = $tcaFieldConfiguration['config']['default'];
-                }
-            }
-        }
-        return $data;
-    }
-
-    /**
-     * @param array $data
-     */
-    public function __construct(array $data)
-    {
-        $this->data = $data;
-    }
-
-    /**
-     * @return array
-     */
-    public function getTableNames()
-    {
-        return array_keys($this->data);
-    }
-
-    /**
-     * @param string $tableName
-     * @return NULL|array
-     */
-    public function getFields($tableName)
-    {
-        $fields = null;
-        if (isset($this->data[$tableName]['fields'])) {
-            $fields = $this->data[$tableName]['fields'];
-        }
-        return $fields;
-    }
-
-    /**
-     * @param string $tableName
-     * @return NULL|int
-     */
-    public function getIdIndex($tableName)
-    {
-        $idIndex = null;
-        if (isset($this->data[$tableName]['idIndex'])) {
-            $idIndex = $this->data[$tableName]['idIndex'];
-        }
-        return $idIndex;
-    }
-
-    /**
-     * @param string $tableName
-     * @return NULL|array
-     */
-    public function getElements($tableName)
-    {
-        $elements = null;
-        if (isset($this->data[$tableName]['elements'])) {
-            $elements = $this->data[$tableName]['elements'];
-        }
-        return $elements;
-    }
-
-    /**
-     * @param string $fileName
-     */
-    public function persist($fileName)
-    {
-        $fileHandle = fopen($fileName, 'w');
-
-        foreach ($this->data as $tableName => $tableData) {
-            if (empty($tableData['fields']) || empty($tableData['elements'])) {
-                continue;
-            }
-
-            $fields = $tableData['fields'];
-            array_unshift($fields, '');
-
-            fputcsv($fileHandle, [$tableName]);
-            fputcsv($fileHandle, $fields);
-
-            foreach ($tableData['elements'] as $element) {
-                array_unshift($element, '');
-                fputcsv($fileHandle, $element);
-            }
-        }
-
-        fclose($fileHandle);
-    }
-}