/** * @test */ public function addDataCallsLanguageServiceForLocalizedPlaceholders() { $labelString = 'LLL:EXT:some_ext/Resources/Private/Language/locallang.xlf:my_placeholder'; $localizedString = 'My Placeholder'; $input = ['tableName' => 'aTable', 'databaseRow' => [], 'processedTca' => ['columns' => ['aField' => ['config' => ['type' => 'input', 'placeholder' => $labelString]]]]]; $expected = $input; $expected['processedTca']['columns']['aField']['config']['placeholder'] = $localizedString; /** @var LanguageService|ObjectProphecy $languageService */ $languageService = $this->prophesize(LanguageService::class); $GLOBALS['LANG'] = $languageService->reveal(); $languageService->sL($labelString)->shouldBeCalled()->willReturn($localizedString); $this->assertSame($expected, $this->subject->addData($input)); }
/** * @test */ public function addDataReturnsValueFromRelationsRecursively() { $input = ['tableName' => 'aTable', 'databaseRow' => ['aField' => '', 'uid_local' => 'sys_file_3|aLabel,sys_file_5|anotherLabel'], 'processedTca' => ['columns' => ['aField' => ['config' => ['type' => 'input', 'placeholder' => '__row|uid_local|metadata|title']], 'uid_local' => ['config' => ['type' => 'group', 'internal_type' => 'db', 'allowed' => 'sys_file']]]]]; $sysFileProphecyResult = ['tableName' => 'sys_file', 'databaseRow' => ['metadata' => '7'], 'processedTca' => ['columns' => ['metadata' => ['config' => ['readOnly' => 1, 'type' => 'inline', 'foreign_table' => 'sys_file_metadata', 'foreign_field' => 'file']]]]]; $sysFileMetadataProphecyResult = ['tableName' => 'sys_file_metadata', 'databaseRow' => ['title' => 'aTitle'], 'processedTca' => ['columns' => ['sha1' => ['config' => ['type' => 'input']]]]]; $sysFileFormDataCompilerProphecy = $this->prophesize(FormDataCompiler::class); GeneralUtility::addInstance(FormDataCompiler::class, $sysFileFormDataCompilerProphecy->reveal()); $sysFileFormDataCompilerProphecy->compile(['command' => 'edit', 'vanillaUid' => 3, 'tableName' => 'sys_file', 'inlineCompileExistingChildren' => false, 'columnsToProcess' => ['metadata']])->shouldBeCalled()->willReturn($sysFileProphecyResult); $sysFileMetaDataFormDataCompilerProphecy = $this->prophesize(FormDataCompiler::class); GeneralUtility::addInstance(FormDataCompiler::class, $sysFileMetaDataFormDataCompilerProphecy->reveal()); $sysFileMetaDataFormDataCompilerProphecy->compile(['command' => 'edit', 'vanillaUid' => 7, 'tableName' => 'sys_file_metadata', 'inlineCompileExistingChildren' => false, 'columnsToProcess' => ['title']])->shouldBeCalled()->willReturn($sysFileMetadataProphecyResult); $expected = $input; $expected['processedTca']['columns']['aField']['config']['placeholder'] = $sysFileMetadataProphecyResult['databaseRow']['title']; $this->assertSame($expected, $this->subject->addData($input)); }