2 namespace TYPO3\CMS\Backend\Tests\UnitDeprecated\Form\FormDataProvider
;
5 * This file is part of the TYPO3 CMS project.
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.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
17 use Prophecy\Argument
;
18 use Prophecy\Prophecy\ObjectProphecy
;
19 use TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexPrepare
;
20 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication
;
21 use TYPO3\CMS\Core\Cache\CacheManager
;
22 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
;
23 use TYPO3\CMS\Core\Utility\GeneralUtility
;
26 * Test case for TcaFlexPrepare to render the functionality when a TCA migration happened
28 class TcaFlexPrepareTest
extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
31 * Subject is not notice free, disable E_NOTICES
33 protected static $suppressNotices = true;
41 * @var BackendUserAuthentication|ObjectProphecy
43 protected $backendUserProphecy;
46 * @var array A backup of registered singleton instances
48 protected $singletonInstances = [];
50 protected function setUp()
52 $this->singletonInstances
= GeneralUtility
::getSingletonInstances();
54 // Suppress cache foo in xml helpers of GeneralUtility
55 /** @var CacheManager|ObjectProphecy $cacheManagerProphecy */
56 $cacheManagerProphecy = $this->prophesize(CacheManager
::class);
57 GeneralUtility
::setSingletonInstance(CacheManager
::class, $cacheManagerProphecy->reveal());
58 $cacheFrontendProphecy = $this->prophesize(FrontendInterface
::class);
59 $cacheManagerProphecy->getCache(Argument
::cetera())->willReturn($cacheFrontendProphecy->reveal());
61 $this->subject
= new TcaFlexPrepare();
64 protected function tearDown()
66 GeneralUtility
::purgeInstances();
67 GeneralUtility
::resetSingletonInstances($this->singletonInstances
);
74 public function addDataMigratesFlexformTca()
77 'systemLanguageRows' => [],
78 'tableName' => 'aTableName',
100 <label>aFlexFieldLabel</label>
103 <default>defaultValue</default>
106 <type>userFunc</type>
107 <userFunc>TYPO3\\CMS\\T3editor\\FormWizard->main</userFunc>
108 <title>t3editor</title>
109 <icon>content-table</icon>
111 <name>wizard_table</name>
114 <format>html</format>
134 $GLOBALS['TCA']['aTableName']['columns'] = $input['processedTca']['columns'];
137 $expected['processedTca']['columns']['aField']['config']['dataStructureIdentifier']
138 = '{"type":"tca","tableName":"aTableName","fieldName":"aField","dataStructureKey":"default"}';
139 $expected['processedTca']['columns']['aField']['config']['ds'] = [
146 'label' => 'aFlexFieldLabel',
149 'default' => 'defaultValue',
150 'renderType' => 't3editor',
161 $this->assertEquals($expected, $this->subject
->addData($input));
167 public function addDataMigratesFlexformTcaInContainer()
170 'systemLanguageRows' => [],
171 'tableName' => 'aTableName',
192 <title>section_1</title>
198 <title>aFlexContainerLabel</title>
202 <label>aFlexFieldLabel</label>
205 <default>defaultValue</default>
208 <type>userFunc</type>
209 <userFunc>TYPO3\\CMS\\T3editor\\FormWizard->main</userFunc>
210 <title>t3editor</title>
211 <icon>content-table</icon>
213 <name>wizard_table</name>
216 <format>html</format>
240 $GLOBALS['TCA']['aTableName']['columns'] = $input['processedTca']['columns'];
243 $expected['processedTca']['columns']['aField']['config']['dataStructureIdentifier']
244 = '{"type":"tca","tableName":"aTableName","fieldName":"aField","dataStructureKey":"default"}';
245 $expected['processedTca']['columns']['aField']['config']['ds'] = [
252 'title' => 'section_1',
256 'aFlexContainer' => [
258 'title' => 'aFlexContainerLabel',
261 'label' => 'aFlexFieldLabel',
264 'default' => 'defaultValue',
265 'renderType' => 't3editor',
280 $this->assertEquals($expected, $this->subject
->addData($input));