[TASK] Make extbase/Tests/Unit/Persistence/Generic/Mapper notice free 24/57224/5
authorChristian Kuhn <lolli@schwarzbu.ch>
Tue, 14 Aug 2018 13:38:46 +0000 (15:38 +0200)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Tue, 14 Aug 2018 14:09:34 +0000 (16:09 +0200)
Releases: master
Resolves: #85267
Change-Id: I2c7ad4775ee9d29903ef914a2ae54d17e0c111d9
Reviewed-on: https://review.typo3.org/57224
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapFactory.php
typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/DataMapFactoryTest.php
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/DataMapperTest.php

index 63999f0..b823b2d 100644 (file)
@@ -226,7 +226,9 @@ class DataMapFactory implements \TYPO3\CMS\Core\SingletonInterface
      */
     protected function getControlSection($tableName)
     {
-        return is_array($GLOBALS['TCA'][$tableName]['ctrl']) ? $GLOBALS['TCA'][$tableName]['ctrl'] : null;
+        return ((isset($GLOBALS['TCA'][$tableName]['ctrl'])) && is_array($GLOBALS['TCA'][$tableName]['ctrl']))
+            ? $GLOBALS['TCA'][$tableName]['ctrl']
+            : null;
     }
 
     /**
@@ -385,10 +387,10 @@ class DataMapFactory implements \TYPO3\CMS\Core\SingletonInterface
     {
         $columnMap->setTypeOfRelation(ColumnMap::RELATION_HAS_ONE);
         $columnMap->setChildTableName($columnConfiguration['foreign_table']);
-        $columnMap->setChildTableWhereStatement($columnConfiguration['foreign_table_where']);
-        $columnMap->setChildSortByFieldName($columnConfiguration['foreign_sortby']);
-        $columnMap->setParentKeyFieldName($columnConfiguration['foreign_field']);
-        $columnMap->setParentTableFieldName($columnConfiguration['foreign_table_field']);
+        $columnMap->setChildTableWhereStatement($columnConfiguration['foreign_table_where'] ?? null);
+        $columnMap->setChildSortByFieldName($columnConfiguration['foreign_sortby'] ?? null);
+        $columnMap->setParentKeyFieldName($columnConfiguration['foreign_field'] ?? null);
+        $columnMap->setParentTableFieldName($columnConfiguration['foreign_table_field'] ?? null);
         if (is_array($columnConfiguration['foreign_match_fields'])) {
             $columnMap->setRelationTableMatchFields($columnConfiguration['foreign_match_fields']);
         }
@@ -407,10 +409,10 @@ class DataMapFactory implements \TYPO3\CMS\Core\SingletonInterface
     {
         $columnMap->setTypeOfRelation(ColumnMap::RELATION_HAS_MANY);
         $columnMap->setChildTableName($columnConfiguration['foreign_table']);
-        $columnMap->setChildTableWhereStatement($columnConfiguration['foreign_table_where']);
-        $columnMap->setChildSortByFieldName($columnConfiguration['foreign_sortby']);
-        $columnMap->setParentKeyFieldName($columnConfiguration['foreign_field']);
-        $columnMap->setParentTableFieldName($columnConfiguration['foreign_table_field']);
+        $columnMap->setChildTableWhereStatement($columnConfiguration['foreign_table_where'] ?? null);
+        $columnMap->setChildSortByFieldName($columnConfiguration['foreign_sortby'] ?? null);
+        $columnMap->setParentKeyFieldName($columnConfiguration['foreign_field'] ?? null);
+        $columnMap->setParentTableFieldName($columnConfiguration['foreign_table_field'] ?? null);
         if (is_array($columnConfiguration['foreign_match_fields'])) {
             $columnMap->setRelationTableMatchFields($columnConfiguration['foreign_match_fields']);
         }
@@ -431,15 +433,15 @@ class DataMapFactory implements \TYPO3\CMS\Core\SingletonInterface
         if (isset($columnConfiguration['MM'])) {
             $columnMap->setTypeOfRelation(ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY);
             $columnMap->setChildTableName($columnConfiguration['foreign_table']);
-            $columnMap->setChildTableWhereStatement($columnConfiguration['foreign_table_where']);
+            $columnMap->setChildTableWhereStatement($columnConfiguration['foreign_table_where'] ?? null);
             $columnMap->setRelationTableName($columnConfiguration['MM']);
-            if (is_array($columnConfiguration['MM_match_fields'])) {
+            if (isset($columnConfiguration['MM_match_fields']) && is_array($columnConfiguration['MM_match_fields'])) {
                 $columnMap->setRelationTableMatchFields($columnConfiguration['MM_match_fields']);
             }
-            if (is_array($columnConfiguration['MM_insert_fields'])) {
+            if (isset($columnConfiguration['MM_insert_fields']) && is_array($columnConfiguration['MM_insert_fields'])) {
                 $columnMap->setRelationTableInsertFields($columnConfiguration['MM_insert_fields']);
             }
-            $columnMap->setRelationTableWhereStatement($columnConfiguration['MM_table_where']);
+            $columnMap->setRelationTableWhereStatement($columnConfiguration['MM_table_where'] ?? null);
             if (!empty($columnConfiguration['MM_opposite_field'])) {
                 $columnMap->setParentKeyFieldName('uid_foreign');
                 $columnMap->setChildKeyFieldName('uid_local');
index ebf1002..1334208 100644 (file)
@@ -233,7 +233,7 @@ class DataMapper implements \TYPO3\CMS\Core\SingletonInterface
         $classSchema = $this->reflectionService->getClassSchema($className);
         $dataMap = $this->getDataMap($className);
         $object->_setProperty('uid', (int)$row['uid']);
-        $object->_setProperty('pid', (int)$row['pid']);
+        $object->_setProperty('pid', (int)($row['pid'] ?? 0));
         $object->_setProperty('_localizedUid', (int)$row['uid']);
         $object->_setProperty('_versionedUid', (int)$row['uid']);
         if ($dataMap->getLanguageIdColumnName() !== null) {
@@ -254,7 +254,7 @@ class DataMapper implements \TYPO3\CMS\Core\SingletonInterface
             $columnName = $columnMap->getColumnName();
             $propertyData = $classSchema->getProperty($propertyName);
             $propertyValue = null;
-            if ($row[$columnName] !== null) {
+            if (isset($row[$columnName])) {
                 switch ($propertyData['type']) {
                     case 'integer':
                         $propertyValue = (int)$row[$columnName];
index d862e33..ff720fb 100644 (file)
@@ -19,18 +19,14 @@ use TYPO3\CMS\Core\DataHandling\TableColumnType;
 use TYPO3\CMS\Extbase\Persistence\Generic\Exception\InvalidClassException;
 use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap;
 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class DataMapFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class DataMapFactoryTest extends UnitTestCase
 {
     /**
-     * Subject is not notice free, disable E_NOTICES
-     */
-    protected static $suppressNotices = true;
-
-    /**
      * @return array
      */
     public function oneToOneRelation()
index d9978db..3b42ade 100644 (file)
@@ -21,18 +21,14 @@ use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap;
 use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper;
 use TYPO3\CMS\Extbase\Reflection\ClassSchema;
 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class DataMapperTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class DataMapperTest extends UnitTestCase
 {
     /**
-     * Subject is not notice free, disable E_NOTICES
-     */
-    protected static $suppressNotices = true;
-
-    /**
      * @test
      */
     public function mapMapsArrayToObjectByCallingmapToObject()