‪TYPO3CMS  9.5
SuggestWizardControllerTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
18 use Psr\Http\Message\ServerRequestInterface;
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
27 class ‪SuggestWizardControllerTest extends UnitTestCase
28 {
33  {
34  $dataStructureIdentifier = '{"type":"tca","tableName":"tt_content","fieldName":"pi_flexform","dataStructureKey":"blog_example,list"}';
35  $serverRequestProphecy = $this->prophesize(ServerRequestInterface::class);
36  $serverRequestProphecy->getParsedBody()->willReturn([
37  'value' => 'theSearchValue',
38  'table' => 'aTable',
39  'field' => 'aField',
40  'uid' => 'aUid',
41  'pid' => 'aPid',
42  'dataStructureIdentifier' => $dataStructureIdentifier,
43  'flexFormSheetName' => 'sDb',
44  'flexFormFieldName' => 'aField',
45  'flexFormContainerName' => '',
46  'flexFormContainerFieldName' => '',
47  ]);
48 
49  $dataStructure = [
50  'sheets' => [
51  'sDb' => [
52  'ROOT' => [
53  'el' => [
54  'differentField' => [
55  'TCEforms' => [
56  'config' => [
57  'Sublevel field configuration',
58  ],
59  ],
60  ],
61  ],
62  ],
63  ],
64  ],
65  ];
66  $flexFormToolsProphecy = $this->prophesize(FlexFormTools::class);
67  GeneralUtility::addInstance(FlexFormTools::class, $flexFormToolsProphecy->reveal());
68  $flexFormToolsProphecy->parseDataStructureByIdentifier($dataStructureIdentifier)->willReturn($dataStructure);
69 
70  $this->expectException(\RuntimeException::class);
71  $this->expectExceptionCode(1480609491);
72  (new ‪SuggestWizardController())->searchAction($serverRequestProphecy->reveal());
73  }
74 
79  {
80  $dataStructureIdentifier = '{"type":"tca","tableName":"tt_content","fieldName":"pi_flexform","dataStructureKey":"blog_example,list"}';
81  $serverRequestProphecy = $this->prophesize(ServerRequestInterface::class);
82  $serverRequestProphecy->getParsedBody()->willReturn([
83  'value' => 'theSearchValue',
84  'table' => 'aTable',
85  'field' => 'aField',
86  'uid' => 'aUid',
87  'pid' => 'aPid',
88  'dataStructureIdentifier' => $dataStructureIdentifier,
89  'flexFormSheetName' => 'sDb',
90  'flexFormFieldName' => 'aField',
91  'flexFormContainerName' => 'aContainer',
92  'flexFormContainerFieldName' => 'aContainerFieldName',
93  ]);
94 
95  $dataStructure = [
96  'sheets' => [
97  'sDb' => [
98  'ROOT' => [
99  'el' => [
100  'notTheFieldYouAreLookingFor' => [
101  'TCEforms' => [
102  'config' => [
103  'Sublevel field configuration',
104  ],
105  ],
106  ],
107  ],
108  ],
109  ],
110  ],
111  ];
112  $flexFormToolsProphecy = $this->prophesize(FlexFormTools::class);
113  GeneralUtility::addInstance(FlexFormTools::class, $flexFormToolsProphecy->reveal());
114  $flexFormToolsProphecy->parseDataStructureByIdentifier($dataStructureIdentifier)->willReturn($dataStructure);
115 
116  $this->expectException(\RuntimeException::class);
117  $this->expectExceptionCode(1480611208);
118  (new ‪SuggestWizardController())->searchAction($serverRequestProphecy->reveal());
119  }
120 
127  public function ‪isTableHiddenIsProperlyRetrieved(bool $expected, array $array): void
128  {
129  $subject = $this->getAccessibleMock(SuggestWizardController::class, ['dummy'], [], '', false);
130  $this->assertEquals($expected, $subject->_call('isTableHidden', $array));
131  }
132 
137  {
138  return [
139  'notSetValue' => [false, ['ctrl' => ['hideTable' => null]]],
140  'true' => [true, ['ctrl' => ['hideTable' => true]]],
141  'false' => [false, ['ctrl' => ['hideTable' => false]]],
142  'string with true' => [true, ['ctrl' => ['hideTable' => '1']]],
143  'string with false' => [false, ['ctrl' => ['hideTable' => '0']]],
144  ];
145  }
146 }
‪TYPO3\CMS\Backend\Tests\Unit\Controller\Wizard\SuggestWizardControllerTest\isTableHiddenIsProperlyRetrieved
‪isTableHiddenIsProperlyRetrieved(bool $expected, array $array)
Definition: SuggestWizardControllerTest.php:127
‪TYPO3\CMS\Backend\Tests\Unit\Controller\Wizard\SuggestWizardControllerTest\isTableHiddenIsProperlyRetrievedDataProvider
‪array isTableHiddenIsProperlyRetrievedDataProvider()
Definition: SuggestWizardControllerTest.php:136
‪TYPO3\CMS\Backend\Tests\Unit\Controller\Wizard\SuggestWizardControllerTest\getFlexFieldConfigurationThrowsExceptionIfSectionContainerFlexFieldIsNotFound
‪getFlexFieldConfigurationThrowsExceptionIfSectionContainerFlexFieldIsNotFound()
Definition: SuggestWizardControllerTest.php:78
‪TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools
Definition: FlexFormTools.php:36
‪TYPO3\CMS\Backend\Controller\Wizard\SuggestWizardController
Definition: SuggestWizardController.php:32
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Backend\Tests\Unit\Controller\Wizard\SuggestWizardControllerTest
Definition: SuggestWizardControllerTest.php:28
‪TYPO3\CMS\Backend\Tests\Unit\Controller\Wizard\SuggestWizardControllerTest\getFlexFieldConfigurationThrowsExceptionIfSimpleFlexFieldIsNotFound
‪getFlexFieldConfigurationThrowsExceptionIfSimpleFlexFieldIsNotFound()
Definition: SuggestWizardControllerTest.php:32
‪TYPO3\CMS\Backend\Tests\Unit\Controller\Wizard
Definition: SuggestWizardControllerTest.php:3