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
;
25 use TYPO3\TestingFramework\Core\Unit\UnitTestCase
;
30 class TcaFlexPrepareTest
extends UnitTestCase
38 * @var BackendUserAuthentication|ObjectProphecy
40 protected $backendUserProphecy;
45 protected function setUp()
47 // Suppress cache foo in xml helpers of GeneralUtility
48 /** @var CacheManager|ObjectProphecy $cacheManagerProphecy */
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());
54 $this->subject
= new TcaFlexPrepare();
60 protected function tearDown()
62 GeneralUtility
::purgeInstances();
69 public function addDataMigratesFlexformTca()
72 'systemLanguageRows' => [],
73 'tableName' => 'aTableName',
95 <label>aFlexFieldLabel</label>
98 <default>defaultValue</default>
101 <type>userFunc</type>
102 <userFunc>TYPO3\\CMS\\T3editor\\FormWizard->main</userFunc>
103 <title>t3editor</title>
104 <icon>content-table</icon>
106 <name>wizard_table</name>
109 <format>html</format>
129 $GLOBALS['TCA']['aTableName']['columns'] = $input['processedTca']['columns'];
132 $expected['processedTca']['columns']['aField']['config']['dataStructureIdentifier']
133 = '{"type":"tca","tableName":"aTableName","fieldName":"aField","dataStructureKey":"default"}';
134 $expected['processedTca']['columns']['aField']['config']['ds'] = [
141 'label' => 'aFlexFieldLabel',
144 'default' => 'defaultValue',
145 'renderType' => 't3editor',
156 $this->assertEquals($expected, $this->subject
->addData($input));
162 public function addDataMigratesFlexformTcaInContainer()
165 'systemLanguageRows' => [],
166 'tableName' => 'aTableName',
187 <title>section_1</title>
193 <title>aFlexContainerLabel</title>
197 <label>aFlexFieldLabel</label>
200 <default>defaultValue</default>
203 <type>userFunc</type>
204 <userFunc>TYPO3\\CMS\\T3editor\\FormWizard->main</userFunc>
205 <title>t3editor</title>
206 <icon>content-table</icon>
208 <name>wizard_table</name>
211 <format>html</format>
235 $GLOBALS['TCA']['aTableName']['columns'] = $input['processedTca']['columns'];
238 $expected['processedTca']['columns']['aField']['config']['dataStructureIdentifier']
239 = '{"type":"tca","tableName":"aTableName","fieldName":"aField","dataStructureKey":"default"}';
240 $expected['processedTca']['columns']['aField']['config']['ds'] = [
247 'title' => 'section_1',
251 'aFlexContainer' => [
253 'title' => 'aFlexContainerLabel',
256 'label' => 'aFlexFieldLabel',
259 'default' => 'defaultValue',
260 'renderType' => 't3editor',
275 $this->assertEquals($expected, $this->subject
->addData($input));