prophesize(CacheManager::class);
GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
$cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
$cacheManagerProphecy->getCache(Argument::cetera())->willReturn($cacheFrontendProphecy->reveal());
$this->subject = new TcaFlexPrepare();
}
/**
* Tear down
*/
protected function tearDown()
{
GeneralUtility::purgeInstances();
parent::tearDown();
}
/**
* @test
*/
public function addDataMigratesFlexformTca()
{
$input = [
'systemLanguageRows' => [],
'tableName' => 'aTableName',
'databaseRow' => [
'aField' => [
'data' => [],
'meta' => [],
],
],
'processedTca' => [
'columns' => [
'aField' => [
'config' => [
'type' => 'flex',
'ds' => [
'default' => '
array
text
defaultValue
userFunc
TYPO3\\CMS\\T3editor\\FormWizard->main
t3editor
content-table
wizard_table
html
',
],
],
],
],
],
];
$GLOBALS['TCA']['aTableName']['columns'] = $input['processedTca']['columns'];
$expected = $input;
$expected['processedTca']['columns']['aField']['config']['dataStructureIdentifier']
= '{"type":"tca","tableName":"aTableName","fieldName":"aField","dataStructureKey":"default"}';
$expected['processedTca']['columns']['aField']['config']['ds'] = [
'sheets' => [
'sDEF' => [
'ROOT' => [
'type' => 'array',
'el' => [
'aFlexField' => [
'label' => 'aFlexFieldLabel',
'config' => [
'type' => 'text',
'default' => 'defaultValue',
'renderType' => 't3editor',
'format' => 'html',
],
],
],
],
],
],
'meta' => [],
];
$this->assertEquals($expected, $this->subject->addData($input));
}
/**
* @test
*/
public function addDataMigratesFlexformTcaInContainer()
{
$input = [
'systemLanguageRows' => [],
'tableName' => 'aTableName',
'databaseRow' => [
'aField' => [
'data' => [],
'meta' => [],
],
],
'processedTca' => [
'columns' => [
'aField' => [
'config' => [
'type' => 'flex',
'ds' => [
'default' => '
array
section_1
array
array
aFlexContainerLabel
text
defaultValue
userFunc
TYPO3\\CMS\\T3editor\\FormWizard->main
t3editor
content-table
wizard_table
html
',
],
],
],
],
],
];
$GLOBALS['TCA']['aTableName']['columns'] = $input['processedTca']['columns'];
$expected = $input;
$expected['processedTca']['columns']['aField']['config']['dataStructureIdentifier']
= '{"type":"tca","tableName":"aTableName","fieldName":"aField","dataStructureKey":"default"}';
$expected['processedTca']['columns']['aField']['config']['ds'] = [
'sheets' => [
'sDEF' => [
'ROOT' => [
'type' => 'array',
'el' => [
'section_1' => [
'title' => 'section_1',
'type' => 'array',
'section' => '1',
'el' => [
'aFlexContainer' => [
'type' => 'array',
'title' => 'aFlexContainerLabel',
'el' => [
'aFlexField' => [
'label' => 'aFlexFieldLabel',
'config' => [
'type' => 'text',
'default' => 'defaultValue',
'renderType' => 't3editor',
'format' => 'html',
],
],
],
],
],
],
],
],
],
],
'meta' => [],
];
$this->assertEquals($expected, $this->subject->addData($input));
}
}