Skip to content

Commit

Permalink
[TASK] Make DataStructureIdentifierHookTest notice free
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
janhelke authored and andreaswolf committed Mar 17, 2018
1 parent 5f8d2b3 commit 04e21be
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
Expand Up @@ -67,7 +67,7 @@ public function getDataStructureIdentifierPostProcess(
): 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']);
}

Expand Down Expand Up @@ -111,7 +111,7 @@ public function parseDataStructureByIdentifierPostProcess(array $dataStructure,
$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'],
Expand Down
@@ -1,4 +1,5 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Form\Tests\Unit\Hooks;

/*
Expand All @@ -19,17 +20,13 @@
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
*/
Expand All @@ -46,7 +43,7 @@ public function setUp()
/**
* Tear down
*/
public function tearDown()
public function tearDown(): void
{
GeneralUtility::resetSingletonInstances($this->singletonInstances);
parent::tearDown();
Expand All @@ -55,7 +52,7 @@ public function tearDown()
/**
* @test
*/
public function getDataStructureIdentifierPostProcessReturnsIdentifierForNotMatchingScenario()
public function getDataStructureIdentifierPostProcessReturnsIdentifierForNotMatchingScenario(): void
{
$givenIdentifier = ['aKey' => 'aValue'];
$result = (new DataStructureIdentifierHook())->getDataStructureIdentifierPostProcess(
Expand All @@ -71,7 +68,7 @@ public function getDataStructureIdentifierPostProcessReturnsIdentifierForNotMatc
/**
* @test
*/
public function getDataStructureIdentifierPostProcessAddDefaultValuesForNewRecord()
public function getDataStructureIdentifierPostProcessAddDefaultValuesForNewRecord(): void
{
$result = (new DataStructureIdentifierHook())->getDataStructureIdentifierPostProcess(
[],
Expand All @@ -89,7 +86,7 @@ public function getDataStructureIdentifierPostProcessAddDefaultValuesForNewRecor
/**
* @test
*/
public function getDataStructureIdentifierPostProcessAddsGivenPersistenceIdentifier()
public function getDataStructureIdentifierPostProcessAddsGivenPersistenceIdentifier(): void
{
$row = [
'CType' => 'form_formframework',
Expand Down Expand Up @@ -128,7 +125,7 @@ public function getDataStructureIdentifierPostProcessAddsGivenPersistenceIdentif
/**
* @test
*/
public function getDataStructureIdentifierPostProcessAddsOverrideFinisherValue()
public function getDataStructureIdentifierPostProcessAddsOverrideFinisherValue(): void
{
$row = [
'CType' => 'form_formframework',
Expand Down Expand Up @@ -163,7 +160,7 @@ public function getDataStructureIdentifierPostProcessAddsOverrideFinisherValue()
/**
* @test
*/
public function parseDataStructureByIdentifierPostProcessReturnsDataStructureUnchanged()
public function parseDataStructureByIdentifierPostProcessReturnsDataStructureUnchanged(): void
{
$dataStructure = ['foo' => 'bar'];
$expected = $dataStructure;
Expand All @@ -181,7 +178,7 @@ public function parseDataStructureByIdentifierPostProcessReturnsDataStructureUnc
* @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());
Expand Down Expand Up @@ -284,7 +281,7 @@ public function parseDataStructureByIdentifierPostProcessDataProvider(): array
*
* @return array
*/
public function implodeArrayKeysReturnsStringDataProvider()
public function implodeArrayKeysReturnsStringDataProvider(): array
{
return [
'One string' => [
Expand Down Expand Up @@ -351,8 +348,10 @@ public function implodeArrayKeysReturnsStringDataProvider()
/**
* @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));
Expand Down

0 comments on commit 04e21be

Please sign in to comment.