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