[TASK] Make DataStructureIdentifierHookTest notice free 74/56274/4
authorJan Helke <typo3@helke.de>
Sat, 17 Mar 2018 09:00:09 +0000 (10:00 +0100)
committerAndreas Wolf <andreas.wolf@typo3.org>
Sat, 17 Mar 2018 13:11:03 +0000 (14:11 +0100)
Releases: master
Resolves: #84398
Change-Id: Iae516ef175b6b6f4e80d92a65acf98a2cacc5eca
Reviewed-on: https://review.typo3.org/56274
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Andreas Wolf <andreas.wolf@typo3.org>
Tested-by: Andreas Wolf <andreas.wolf@typo3.org>
typo3/sysext/form/Classes/Hooks/DataStructureIdentifierHook.php
typo3/sysext/form/Tests/Unit/Hooks/DataStructureIdentifierHookTest.php

index 8b80202..fa775c5 100644 (file)
@@ -67,7 +67,7 @@ class DataStructureIdentifierHook
     ): array {
         if ($tableName === 'tt_content' && $fieldName === 'pi_flexform' && $row['CType'] === 'form_formframework') {
             $currentFlexData = [];
-            if (!is_array($row['pi_flexform']) && !empty($row['pi_flexform'])) {
+            if (!empty($row['pi_flexform']) && !\is_array($row['pi_flexform'])) {
                 $currentFlexData = GeneralUtility::xml2array($row['pi_flexform']);
             }
 
@@ -111,7 +111,7 @@ class DataStructureIdentifierHook
                         $formIsAccessible = true;
                     }
 
-                    if ($form['invalid']) {
+                    if (isset($form['invalid']) && $form['invalid']) {
                         $dataStructure['sheets']['sDEF']['ROOT']['el']['settings.persistenceIdentifier']['TCEforms']['config']['items'][] = [
                             $form['name'] . ' (' . $form['persistenceIdentifier'] . ')',
                             $form['persistenceIdentifier'],
index 738a61a..b9a438a 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 namespace TYPO3\CMS\Form\Tests\Unit\Hooks;
 
 /*
@@ -19,18 +20,14 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Form\Hooks\DataStructureIdentifierHook;
 use TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManager;
 use TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManagerInterface;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class DataStructureIdentifierHookTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class DataStructureIdentifierHookTest extends UnitTestCase
 {
     /**
-     * Subject is not notice free, disable E_NOTICES
-     */
-    protected static $suppressNotices = true;
-
-    /**
      * @var array A backup of registered singleton instances
      */
     protected $singletonInstances = [];
@@ -46,7 +43,7 @@ class DataStructureIdentifierHookTest extends \TYPO3\TestingFramework\Core\Unit\
     /**
      * Tear down
      */
-    public function tearDown()
+    public function tearDown(): void
     {
         GeneralUtility::resetSingletonInstances($this->singletonInstances);
         parent::tearDown();
@@ -55,7 +52,7 @@ class DataStructureIdentifierHookTest extends \TYPO3\TestingFramework\Core\Unit\
     /**
      * @test
      */
-    public function getDataStructureIdentifierPostProcessReturnsIdentifierForNotMatchingScenario()
+    public function getDataStructureIdentifierPostProcessReturnsIdentifierForNotMatchingScenario(): void
     {
         $givenIdentifier = ['aKey' => 'aValue'];
         $result = (new DataStructureIdentifierHook())->getDataStructureIdentifierPostProcess(
@@ -71,7 +68,7 @@ class DataStructureIdentifierHookTest extends \TYPO3\TestingFramework\Core\Unit\
     /**
      * @test
      */
-    public function getDataStructureIdentifierPostProcessAddDefaultValuesForNewRecord()
+    public function getDataStructureIdentifierPostProcessAddDefaultValuesForNewRecord(): void
     {
         $result = (new DataStructureIdentifierHook())->getDataStructureIdentifierPostProcess(
             [],
@@ -89,7 +86,7 @@ class DataStructureIdentifierHookTest extends \TYPO3\TestingFramework\Core\Unit\
     /**
      * @test
      */
-    public function getDataStructureIdentifierPostProcessAddsGivenPersistenceIdentifier()
+    public function getDataStructureIdentifierPostProcessAddsGivenPersistenceIdentifier(): void
     {
         $row = [
             'CType' => 'form_formframework',
@@ -128,7 +125,7 @@ class DataStructureIdentifierHookTest extends \TYPO3\TestingFramework\Core\Unit\
     /**
      * @test
      */
-    public function getDataStructureIdentifierPostProcessAddsOverrideFinisherValue()
+    public function getDataStructureIdentifierPostProcessAddsOverrideFinisherValue(): void
     {
         $row = [
             'CType' => 'form_formframework',
@@ -163,7 +160,7 @@ class DataStructureIdentifierHookTest extends \TYPO3\TestingFramework\Core\Unit\
     /**
      * @test
      */
-    public function parseDataStructureByIdentifierPostProcessReturnsDataStructureUnchanged()
+    public function parseDataStructureByIdentifierPostProcessReturnsDataStructureUnchanged(): void
     {
         $dataStructure = ['foo' => 'bar'];
         $expected = $dataStructure;
@@ -181,7 +178,7 @@ class DataStructureIdentifierHookTest extends \TYPO3\TestingFramework\Core\Unit\
      * @param array $formDefinition
      * @param array $expectedItem
      */
-    public function parseDataStructureByIdentifierPostProcessAddsExistingFormItems(array $formDefinition, array $expectedItem)
+    public function parseDataStructureByIdentifierPostProcessAddsExistingFormItems(array $formDefinition, array $expectedItem): void
     {
         $objectManagerProphecy = $this->prophesize(ObjectManager::class);
         GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
@@ -284,7 +281,7 @@ class DataStructureIdentifierHookTest extends \TYPO3\TestingFramework\Core\Unit\
      *
      * @return array
      */
-    public function implodeArrayKeysReturnsStringDataProvider()
+    public function implodeArrayKeysReturnsStringDataProvider(): array
     {
         return [
             'One string' => [
@@ -351,8 +348,10 @@ class DataStructureIdentifierHookTest extends \TYPO3\TestingFramework\Core\Unit\
     /**
      * @dataProvider implodeArrayKeysReturnsStringDataProvider
      * @test
+     * @param array $array
+     * @param string $expectation
      */
-    public function implodeArrayKeysReturnsString($array, $expectation)
+    public function implodeArrayKeysReturnsString(array $array, string $expectation): void
     {
         $hookMock = $this->getAccessibleMock(DataStructureIdentifierHook::class, [ 'dummy' ], [], '', false);
         $this->assertEquals($expectation, $hookMock->_call('implodeArrayKeys', $array));