2 declare(strict_types
= 1);
3 namespace TYPO3\CMS\Backend\Tests\UnitDeprecated\Form\FormDataProvider
;
6 * This file is part of the TYPO3 CMS project.
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.
12 * For the full copyright and license information, please read the
13 * LICENSE.txt file that was distributed with this source code.
15 * The TYPO3 project - inspiring people to share!
18 use Prophecy\Argument
;
19 use Prophecy\Prophecy\ObjectProphecy
;
20 use TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexPrepare
;
21 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication
;
22 use TYPO3\CMS\Core\Cache\CacheManager
;
23 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
;
24 use TYPO3\CMS\Core\Utility\GeneralUtility
;
27 * Test case for TcaFlexPrepare to render the functionality when a TCA migration happened
29 class TcaFlexPrepareTest
extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
37 * @var BackendUserAuthentication|ObjectProphecy
39 protected $backendUserProphecy;
42 * @var array A backup of registered singleton instances
44 protected $singletonInstances = [];
46 protected function setUp()
48 $this->singletonInstances
= GeneralUtility
::getSingletonInstances();
50 // Suppress cache foo in xml helpers of GeneralUtility
51 /** @var CacheManager|ObjectProphecy $cacheManagerProphecy */
52 $cacheManagerProphecy = $this->prophesize(CacheManager
::class);
53 GeneralUtility
::setSingletonInstance(CacheManager
::class, $cacheManagerProphecy->reveal());
54 $cacheFrontendProphecy = $this->prophesize(FrontendInterface
::class);
55 $cacheManagerProphecy->getCache(Argument
::cetera())->willReturn($cacheFrontendProphecy->reveal());
57 $this->subject
= new TcaFlexPrepare();
60 protected function tearDown()
62 GeneralUtility
::purgeInstances();
63 GeneralUtility
::resetSingletonInstances($this->singletonInstances
);
70 public function addDataMigratesFlexformTca()
73 'systemLanguageRows' => [],
74 'tableName' => 'aTableName',
96 <label>aFlexFieldLabel</label>
99 <default>defaultValue</default>
102 <type>userFunc</type>
103 <userFunc>TYPO3\\CMS\\T3editor\\FormWizard->main</userFunc>
104 <title>t3editor</title>
105 <icon>content-table</icon>
107 <name>wizard_table</name>
110 <format>html</format>
130 $GLOBALS['TCA']['aTableName']['columns'] = $input['processedTca']['columns'];
133 $expected['processedTca']['columns']['aField']['config']['dataStructureIdentifier']
134 = '{"type":"tca","tableName":"aTableName","fieldName":"aField","dataStructureKey":"default"}';
135 $expected['processedTca']['columns']['aField']['config']['ds'] = [
142 'label' => 'aFlexFieldLabel',
145 'default' => 'defaultValue',
146 'renderType' => 't3editor',
157 $this->assertEquals($expected, $this->subject
->addData($input));
163 public function addDataMigratesFlexformTcaInContainer()
166 'systemLanguageRows' => [],
167 'tableName' => 'aTableName',
188 <title>section_1</title>
194 <title>aFlexContainerLabel</title>
198 <label>aFlexFieldLabel</label>
201 <default>defaultValue</default>
204 <type>userFunc</type>
205 <userFunc>TYPO3\\CMS\\T3editor\\FormWizard->main</userFunc>
206 <title>t3editor</title>
207 <icon>content-table</icon>
209 <name>wizard_table</name>
212 <format>html</format>
236 $GLOBALS['TCA']['aTableName']['columns'] = $input['processedTca']['columns'];
239 $expected['processedTca']['columns']['aField']['config']['dataStructureIdentifier']
240 = '{"type":"tca","tableName":"aTableName","fieldName":"aField","dataStructureKey":"default"}';
241 $expected['processedTca']['columns']['aField']['config']['ds'] = [
248 'title' => 'section_1',
252 'aFlexContainer' => [
254 'title' => 'aFlexContainerLabel',
257 'label' => 'aFlexFieldLabel',
260 'default' => 'defaultValue',
261 'renderType' => 't3editor',
276 $this->assertEquals($expected, $this->subject
->addData($input));