‪TYPO3CMS  9.5
TcaFlexPrepareTest.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 Prophecy\Argument;
19 use Prophecy\Prophecy\ObjectProphecy;
25 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
26 
30 class ‪TcaFlexPrepareTest extends UnitTestCase
31 {
35  protected ‪$subject;
36 
40  protected ‪$backendUserProphecy;
41 
45  protected function ‪setUp()
46  {
47  // Suppress cache foo in xml helpers of GeneralUtility
49  $cacheManagerProphecy = $this->prophesize(CacheManager::class);
50  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
51  $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
52  $cacheManagerProphecy->getCache(Argument::cetera())->willReturn($cacheFrontendProphecy->reveal());
53 
54  $this->subject = new ‪TcaFlexPrepare();
55  }
56 
60  protected function ‪tearDown()
61  {
62  GeneralUtility::purgeInstances();
63  parent::tearDown();
64  }
65 
69  public function ‪addDataMigratesFlexformTca()
70  {
71  $input = [
72  'systemLanguageRows' => [],
73  'tableName' => 'aTableName',
74  'databaseRow' => [
75  'aField' => [
76  'data' => [],
77  'meta' => [],
78  ],
79  ],
80  'processedTca' => [
81  'columns' => [
82  'aField' => [
83  'config' => [
84  'type' => 'flex',
85  'ds' => [
86  'default' => '
87  <T3DataStructure>
88  <sheets>
89  <sDEF>
90  <ROOT>
91  <type>array</type>
92  <el>
93  <aFlexField>
94  <TCEforms>
95  <label>aFlexFieldLabel</label>
96  <config>
97  <type>text</type>
98  <default>defaultValue</default>
99  <wizards>
100  <t3editor>
101  <type>userFunc</type>
102  <userFunc>TYPO3\\CMS\\T3editor\\FormWizard->main</userFunc>
103  <title>t3editor</title>
104  <icon>content-table</icon>
105  <module>
106  <name>wizard_table</name>
107  </module>
108  <params>
109  <format>html</format>
110  </params>
111  </t3editor>
112  </wizards>
113  </config>
114  </TCEforms>
115  </aFlexField>
116  </el>
117  </ROOT>
118  </sDEF>
119  </sheets>
120  </T3DataStructure>
121  ',
122  ],
123  ],
124  ],
125  ],
126  ],
127  ];
128 
129  ‪$GLOBALS['TCA']['aTableName']['columns'] = $input['processedTca']['columns'];
130 
131  $expected = $input;
132  $expected['processedTca']['columns']['aField']['config']['dataStructureIdentifier']
133  = '{"type":"tca","tableName":"aTableName","fieldName":"aField","dataStructureKey":"default"}';
134  $expected['processedTca']['columns']['aField']['config']['ds'] = [
135  'sheets' => [
136  'sDEF' => [
137  'ROOT' => [
138  'type' => 'array',
139  'el' => [
140  'aFlexField' => [
141  'label' => 'aFlexFieldLabel',
142  'config' => [
143  'type' => 'text',
144  'default' => 'defaultValue',
145  'renderType' => 't3editor',
146  'format' => 'html',
147  ],
148  ],
149  ],
150  ],
151  ],
152  ],
153  'meta' => [],
154  ];
155 
156  $this->assertEquals($expected, $this->subject->addData($input));
157  }
158 
163  {
164  $input = [
165  'systemLanguageRows' => [],
166  'tableName' => 'aTableName',
167  'databaseRow' => [
168  'aField' => [
169  'data' => [],
170  'meta' => [],
171  ],
172  ],
173  'processedTca' => [
174  'columns' => [
175  'aField' => [
176  'config' => [
177  'type' => 'flex',
178  'ds' => [
179  'default' => '
180  <T3DataStructure>
181  <sheets>
182  <sDEF>
183  <ROOT>
184  <type>array</type>
185  <el>
186  <section_1>
187  <title>section_1</title>
188  <type>array</type>
189  <section>1</section>
190  <el>
191  <aFlexContainer>
192  <type>array</type>
193  <title>aFlexContainerLabel</title>
194  <el>
195  <aFlexField>
196  <TCEforms>
197  <label>aFlexFieldLabel</label>
198  <config>
199  <type>text</type>
200  <default>defaultValue</default>
201  <wizards>
202  <t3editor>
203  <type>userFunc</type>
204  <userFunc>TYPO3\\CMS\\T3editor\\FormWizard->main</userFunc>
205  <title>t3editor</title>
206  <icon>content-table</icon>
207  <module>
208  <name>wizard_table</name>
209  </module>
210  <params>
211  <format>html</format>
212  </params>
213  </t3editor>
214  </wizards>
215  </config>
216  </TCEforms>
217  </aFlexField>
218  </el>
219  </aFlexContainer>
220  </el>
221  </section_1>
222  </el>
223  </ROOT>
224  </sDEF>
225  </sheets>
226  </T3DataStructure>
227  ',
228  ],
229  ],
230  ],
231  ],
232  ],
233  ];
234 
235  ‪$GLOBALS['TCA']['aTableName']['columns'] = $input['processedTca']['columns'];
236 
237  $expected = $input;
238  $expected['processedTca']['columns']['aField']['config']['dataStructureIdentifier']
239  = '{"type":"tca","tableName":"aTableName","fieldName":"aField","dataStructureKey":"default"}';
240  $expected['processedTca']['columns']['aField']['config']['ds'] = [
241  'sheets' => [
242  'sDEF' => [
243  'ROOT' => [
244  'type' => 'array',
245  'el' => [
246  'section_1' => [
247  'title' => 'section_1',
248  'type' => 'array',
249  'section' => '1',
250  'el' => [
251  'aFlexContainer' => [
252  'type' => 'array',
253  'title' => 'aFlexContainerLabel',
254  'el' => [
255  'aFlexField' => [
256  'label' => 'aFlexFieldLabel',
257  'config' => [
258  'type' => 'text',
259  'default' => 'defaultValue',
260  'renderType' => 't3editor',
261  'format' => 'html',
262  ],
263  ],
264  ],
265  ],
266  ],
267  ],
268  ],
269  ],
270  ],
271  ],
272  'meta' => [],
273  ];
274 
275  $this->assertEquals($expected, $this->subject->addData($input));
276  }
277 }
‪TYPO3\CMS\Backend\Tests\UnitDeprecated\Form\FormDataProvider\TcaFlexPrepareTest
Definition: TcaFlexPrepareTest.php:31
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexPrepare
Definition: TcaFlexPrepare.php:34
‪TYPO3\CMS\Backend\Tests\UnitDeprecated\Form\FormDataProvider\TcaFlexPrepareTest\$backendUserProphecy
‪BackendUserAuthentication ObjectProphecy $backendUserProphecy
Definition: TcaFlexPrepareTest.php:38
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:34
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:45
‪TYPO3\CMS\Backend\Tests\UnitDeprecated\Form\FormDataProvider\TcaFlexPrepareTest\addDataMigratesFlexformTcaInContainer
‪addDataMigratesFlexformTcaInContainer()
Definition: TcaFlexPrepareTest.php:160
‪TYPO3\CMS\Backend\Tests\UnitDeprecated\Form\FormDataProvider
Definition: DatabaseRowInitializeNewTest.php:3
‪TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
Definition: FrontendInterface.php:21
‪TYPO3\CMS\Backend\Tests\UnitDeprecated\Form\FormDataProvider\TcaFlexPrepareTest\$subject
‪TcaFlexPrepare $subject
Definition: TcaFlexPrepareTest.php:34
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Backend\Tests\UnitDeprecated\Form\FormDataProvider\TcaFlexPrepareTest\tearDown
‪tearDown()
Definition: TcaFlexPrepareTest.php:58
‪TYPO3\CMS\Backend\Tests\UnitDeprecated\Form\FormDataProvider\TcaFlexPrepareTest\addDataMigratesFlexformTca
‪addDataMigratesFlexformTca()
Definition: TcaFlexPrepareTest.php:67
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Backend\Tests\UnitDeprecated\Form\FormDataProvider\TcaFlexPrepareTest\setUp
‪setUp()
Definition: TcaFlexPrepareTest.php:43