2 namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
17 use Prophecy\Prophecy\ObjectProphecy;
21 use TYPO3\CMS\Core\Tests\UnitTestCase;
46 'tableName' =>
'aTable',
61 unset($expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'placeholder']);
63 $this->assertSame($expected, $this->subject->addData($input));
72 'tableName' =>
'aTable',
79 'placeholder' =>
'aPlaceholder',
88 $this->assertSame($expected, $this->subject->addData($input));
97 'tableName' =>
'aTable',
99 'anotherField' =>
'anotherPlaceholder'
106 'placeholder' =>
'__row|anotherField',
114 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'placeholder'] =
'anotherPlaceholder';
116 $this->assertSame($expected, $this->subject->addData($input));
122 public function addDataReturnsValueFromSelectTypeRelation()
125 'tableName' =>
'aTable',
128 'aRelationField' => [
'42'],
135 'placeholder' =>
'__row|aRelationField|aForeignField',
138 'aRelationField' => [
141 'foreign_table' =>
'aForeignTable'
148 $aForeignTableInput = [
149 'tableName' =>
'aForeignTable',
151 'aForeignField' =>
'aForeignValue',
165 $formDataCompilerProphecy = $this->prophesize(FormDataCompiler::class);
167 $formDataCompilerProphecy->compile([
170 'tableName' =>
'aForeignTable',
171 'inlineCompileExistingChildren' =>
false,
172 'columnsToProcess' => [
'aForeignField']
175 ->willReturn($aForeignTableInput);
178 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'placeholder'] = $aForeignTableInput[
'databaseRow'][
'aForeignField'];
180 $this->assertSame($expected, $this->subject->addData($input));
189 'tableName' =>
'aTable',
192 'aRelationField' => [],
199 'placeholder' =>
'__row|aRelationField|aForeignField',
202 'aRelationField' => [
205 'foreign_table' =>
'aForeignTable'
213 unset($expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'placeholder']);
215 $this->assertSame($expected, $this->subject->addData($input));
221 public function addDataReturnsValueFromGroupTypeRelation()
224 'tableName' =>
'aTable',
227 'uid_local' =>
'sys_file_3|aLabel,sys_file_5|anotherLabel',
234 'placeholder' =>
'__row|uid_local|sha1',
240 'internal_type' =>
'db',
241 'allowed' =>
'sys_file'
248 $sysFileProphecyResult = [
249 'tableName' =>
'sys_file',
251 'sha1' =>
'aSha1Value',
265 $formDataCompilerProphecy = $this->prophesize(FormDataCompiler::class);
267 $formDataCompilerProphecy->compile([
270 'tableName' =>
'sys_file',
271 'inlineCompileExistingChildren' =>
false,
272 'columnsToProcess' => [
'sha1']
275 ->willReturn($sysFileProphecyResult);
278 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'placeholder'] = $sysFileProphecyResult[
'databaseRow'][
'sha1'];
280 $this->assertSame($expected, $this->subject->addData($input));
286 public function addDataReturnsValueFromInlineTypeRelation()
289 'tableName' =>
'aTable',
299 'placeholder' =>
'__row|metadata|title',
306 'foreign_table' =>
'sys_file_metadata',
307 'foreign_field' =>
'file',
314 $sysFileMetadataProphecyResult = [
315 'tableName' =>
'sys_file_metadata',
331 $formDataCompilerProphecy = $this->prophesize(FormDataCompiler::class);
333 $formDataCompilerProphecy->compile([
336 'tableName' =>
'sys_file_metadata',
337 'inlineCompileExistingChildren' =>
false,
338 'columnsToProcess' => [
'title']
341 ->willReturn($sysFileMetadataProphecyResult);
344 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'placeholder'] = $sysFileMetadataProphecyResult[
'databaseRow'][
'title'];
346 $this->assertSame($expected, $this->subject->addData($input));
355 'tableName' =>
'aTable',
358 'uid_local' =>
'sys_file_3|aLabel,sys_file_5|anotherLabel',
365 'placeholder' =>
'__row|uid_local|metadata|title',
371 'internal_type' =>
'db',
372 'allowed' =>
'sys_file'
379 $sysFileProphecyResult = [
380 'tableName' =>
'sys_file',
390 'foreign_table' =>
'sys_file_metadata',
391 'foreign_field' =>
'file',
398 $sysFileMetadataProphecyResult = [
399 'tableName' =>
'sys_file_metadata',
414 $sysFileFormDataCompilerProphecy = $this->prophesize(FormDataCompiler::class);
416 $sysFileFormDataCompilerProphecy->compile([
419 'tableName' =>
'sys_file',
420 'inlineCompileExistingChildren' =>
false,
421 'columnsToProcess' => [
'metadata']
424 ->willReturn($sysFileProphecyResult);
426 $sysFileMetaDataFormDataCompilerProphecy = $this->prophesize(FormDataCompiler::class);
428 $sysFileMetaDataFormDataCompilerProphecy->compile([
431 'tableName' =>
'sys_file_metadata',
432 'inlineCompileExistingChildren' =>
false,
433 'columnsToProcess' => [
'title']
436 ->willReturn($sysFileMetadataProphecyResult);
439 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'placeholder'] = $sysFileMetadataProphecyResult[
'databaseRow'][
'title'];
441 $this->assertSame($expected, $this->subject->addData($input));
447 public function addDataCallsLanguageServiceForLocalizedPlaceholders()
449 $labelString =
'LLL:EXT:some_ext/Resources/Private/Language/locallang.xlf:my_placeholder';
450 $localizedString =
'My Placeholder';
452 'tableName' =>
'aTable',
459 'placeholder' => $labelString,
466 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'placeholder'] = $localizedString;
469 $languageService = $this->prophesize(LanguageService::class);
470 $GLOBALS[
'LANG'] = $languageService->reveal();
471 $languageService->sL($labelString)->shouldBeCalled()->willReturn($localizedString);
473 $this->assertSame($expected, $this->subject->addData($input));