‪TYPO3CMS  10.4
SuggestWizardControllerTest.php
Go to the documentation of this file.
1 <?php
2 
3 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 
19 
20 use Psr\Http\Message\ServerRequestInterface;
24 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
25 
29 class ‪SuggestWizardControllerTest extends UnitTestCase
30 {
35  {
36  $dataStructureIdentifier = '{"type":"tca","tableName":"tt_content","fieldName":"pi_flexform","dataStructureKey":"blog_example,list"}';
37  $serverRequestProphecy = $this->prophesize(ServerRequestInterface::class);
38  $serverRequestProphecy->getParsedBody()->willReturn([
39  'value' => 'theSearchValue',
40  'table' => 'aTable',
41  'field' => 'aField',
42  'uid' => 'aUid',
43  'pid' => 'aPid',
44  'dataStructureIdentifier' => $dataStructureIdentifier,
45  'flexFormSheetName' => 'sDb',
46  'flexFormFieldName' => 'aField',
47  'flexFormContainerName' => '',
48  'flexFormContainerFieldName' => '',
49  ]);
50 
51  $dataStructure = [
52  'sheets' => [
53  'sDb' => [
54  'ROOT' => [
55  'el' => [
56  'differentField' => [
57  'TCEforms' => [
58  'config' => [
59  'Sublevel field configuration',
60  ],
61  ],
62  ],
63  ],
64  ],
65  ],
66  ],
67  ];
68  $flexFormToolsProphecy = $this->prophesize(FlexFormTools::class);
69  GeneralUtility::addInstance(FlexFormTools::class, $flexFormToolsProphecy->reveal());
70  $flexFormToolsProphecy->parseDataStructureByIdentifier($dataStructureIdentifier)->willReturn($dataStructure);
71 
72  $this->expectException(\RuntimeException::class);
73  $this->expectExceptionCode(1480609491);
74  (new ‪SuggestWizardController())->searchAction($serverRequestProphecy->reveal());
75  }
76 
81  {
82  $dataStructureIdentifier = '{"type":"tca","tableName":"tt_content","fieldName":"pi_flexform","dataStructureKey":"blog_example,list"}';
83  $serverRequestProphecy = $this->prophesize(ServerRequestInterface::class);
84  $serverRequestProphecy->getParsedBody()->willReturn([
85  'value' => 'theSearchValue',
86  'table' => 'aTable',
87  'field' => 'aField',
88  'uid' => 'aUid',
89  'pid' => 'aPid',
90  'dataStructureIdentifier' => $dataStructureIdentifier,
91  'flexFormSheetName' => 'sDb',
92  'flexFormFieldName' => 'aField',
93  'flexFormContainerName' => 'aContainer',
94  'flexFormContainerFieldName' => 'aContainerFieldName',
95  ]);
96 
97  $dataStructure = [
98  'sheets' => [
99  'sDb' => [
100  'ROOT' => [
101  'el' => [
102  'notTheFieldYouAreLookingFor' => [
103  'TCEforms' => [
104  'config' => [
105  'Sublevel field configuration',
106  ],
107  ],
108  ],
109  ],
110  ],
111  ],
112  ],
113  ];
114  $flexFormToolsProphecy = $this->prophesize(FlexFormTools::class);
115  GeneralUtility::addInstance(FlexFormTools::class, $flexFormToolsProphecy->reveal());
116  $flexFormToolsProphecy->parseDataStructureByIdentifier($dataStructureIdentifier)->willReturn($dataStructure);
117 
118  $this->expectException(\RuntimeException::class);
119  $this->expectExceptionCode(1480611208);
120  (new ‪SuggestWizardController())->searchAction($serverRequestProphecy->reveal());
121  }
122 
129  public function ‪isTableHiddenIsProperlyRetrieved(bool $expected, array $array): void
130  {
131  $subject = $this->getAccessibleMock(SuggestWizardController::class, ['dummy'], [], '', false);
132  self::assertEquals($expected, $subject->_call('isTableHidden', $array));
133  }
134 
139  {
140  return [
141  'notSetValue' => [false, ['ctrl' => ['hideTable' => null]]],
142  'true' => [true, ['ctrl' => ['hideTable' => true]]],
143  'false' => [false, ['ctrl' => ['hideTable' => false]]],
144  'string with true' => [true, ['ctrl' => ['hideTable' => '1']]],
145  'string with false' => [false, ['ctrl' => ['hideTable' => '0']]],
146  ];
147  }
148 }
‪TYPO3\CMS\Backend\Tests\Unit\Controller\Wizard\SuggestWizardControllerTest\isTableHiddenIsProperlyRetrieved
‪isTableHiddenIsProperlyRetrieved(bool $expected, array $array)
Definition: SuggestWizardControllerTest.php:129
‪TYPO3\CMS\Backend\Tests\Unit\Controller\Wizard\SuggestWizardControllerTest\isTableHiddenIsProperlyRetrievedDataProvider
‪array isTableHiddenIsProperlyRetrievedDataProvider()
Definition: SuggestWizardControllerTest.php:138
‪TYPO3\CMS\Backend\Tests\Unit\Controller\Wizard\SuggestWizardControllerTest\getFlexFieldConfigurationThrowsExceptionIfSectionContainerFlexFieldIsNotFound
‪getFlexFieldConfigurationThrowsExceptionIfSectionContainerFlexFieldIsNotFound()
Definition: SuggestWizardControllerTest.php:80
‪TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools
Definition: FlexFormTools.php:38
‪TYPO3\CMS\Backend\Controller\Wizard\SuggestWizardController
Definition: SuggestWizardController.php:33
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Backend\Tests\Unit\Controller\Wizard\SuggestWizardControllerTest
Definition: SuggestWizardControllerTest.php:30
‪TYPO3\CMS\Backend\Tests\Unit\Controller\Wizard\SuggestWizardControllerTest\getFlexFieldConfigurationThrowsExceptionIfSimpleFlexFieldIsNotFound
‪getFlexFieldConfigurationThrowsExceptionIfSimpleFlexFieldIsNotFound()
Definition: SuggestWizardControllerTest.php:34
‪TYPO3\CMS\Backend\Tests\Unit\Controller\Wizard
Definition: SuggestWizardControllerTest.php:18