From 04e21be62143aed51f6113bccadc11eb9309e65c Mon Sep 17 00:00:00 2001 From: Jan Helke <typo3@helke.de> Date: Sat, 17 Mar 2018 10:00:09 +0100 Subject: [PATCH] [TASK] Make DataStructureIdentifierHookTest notice free 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> --- .../Hooks/DataStructureIdentifierHook.php | 4 +-- .../Hooks/DataStructureIdentifierHookTest.php | 29 +++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/typo3/sysext/form/Classes/Hooks/DataStructureIdentifierHook.php b/typo3/sysext/form/Classes/Hooks/DataStructureIdentifierHook.php index 8b802029c009..fa775c59b490 100644 --- a/typo3/sysext/form/Classes/Hooks/DataStructureIdentifierHook.php +++ b/typo3/sysext/form/Classes/Hooks/DataStructureIdentifierHook.php @@ -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'], diff --git a/typo3/sysext/form/Tests/Unit/Hooks/DataStructureIdentifierHookTest.php b/typo3/sysext/form/Tests/Unit/Hooks/DataStructureIdentifierHookTest.php index 738a61a081de..b9a438a5d505 100644 --- a/typo3/sysext/form/Tests/Unit/Hooks/DataStructureIdentifierHookTest.php +++ b/typo3/sysext/form/Tests/Unit/Hooks/DataStructureIdentifierHookTest.php @@ -1,4 +1,5 @@ <?php +declare(strict_types = 1); namespace TYPO3\CMS\Form\Tests\Unit\Hooks; /* @@ -19,17 +20,13 @@ 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 */ @@ -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)); -- GitLab