2 namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
17 use Prophecy\Argument;
18 use Prophecy\Prophecy\ObjectProphecy;
20 use TYPO3\CMS\Core\Tests\UnitTestCase;
41 $this->timeZone = date_default_timezone_get();
42 date_default_timezone_set(
'UTC');
47 date_default_timezone_set($this->timeZone);
56 'tableName' =>
'aTable',
62 $this->setExpectedException(\UnexpectedValueException::class, $this->any(), 1443706103);
63 $this->subject->addData($input);
72 'tableName' =>
'aTable',
77 'label_userFunc' =>
function (&$parameters) {
78 $parameters[
'title'] =
'Test';
86 $expected[
'recordTitle'] =
'Test';
88 $this->assertSame($expected, $this->subject->addData($input));
97 'tableName' =>
'aTable',
99 'isInlineChild' =>
true,
103 'formattedLabel_userFunc' =>
function (&$parameters) {
104 $parameters[
'title'] =
'Test';
112 $expected[
'recordTitle'] =
'Test';
114 $this->assertSame($expected, $this->subject->addData($input));
123 'tableName' =>
'aTable',
125 'aField' =>
'aValue',
139 'isInlineChild' =>
true,
140 'inlineParentConfig' => [
141 'foreign_label' =>
'aField',
145 $expected[
'recordTitle'] =
'aValue';
146 $this->assertSame($expected, $this->subject->addData($input));
155 'tableName' =>
'aTable',
157 'aField' =>
'aValue',
171 'isInlineChild' =>
true,
172 'inlineParentConfig' => [
173 'symmetric_label' =>
'aField',
175 'isOnSymmetricSide' =>
true,
178 $expected[
'recordTitle'] =
'aValue';
179 $this->assertSame($expected, $this->subject->addData($input));
185 public function addDataReturnsRecordTitleForUid()
188 'tableName' =>
'aTable',
190 'uid' =>
'NEW56017ee37d10e587251374',
201 $languageService = $this->prophesize(LanguageService::class);
202 $GLOBALS[
'LANG'] = $languageService->reveal();
203 $languageService->sL(Argument::cetera())->willReturnArgument(0);
206 $expected[
'recordTitle'] =
'NEW56017ee37d10e587251374';
207 $this->assertSame($expected, $this->subject->addData($input));
229 'plain text input' => [
242 '01-01-01 (-7 days)',
244 'date input (dbType: date)' => [
251 '01-01-01 (-7 days)',
253 'date input (disableAgeDisplay: TRUE)' => [
257 'disableAgeDisplay' => true
278 'datetime input' => [
281 'eval' =>
'datetime',
287 'datetime input (dbType: datetime)' => [
290 'eval' =>
'datetime',
291 'dbType' =>
'datetime'
293 '2014-12-31 23:59:59',
307 public function addDataReturnsRecordTitleForInputType($fieldConfig, $fieldValue, $expectedTitle)
310 'tableName' =>
'aTable',
313 'aField' => $fieldValue,
321 'config' => $fieldConfig,
328 $languageService = $this->prophesize(LanguageService::class);
329 $GLOBALS[
'LANG'] = $languageService->reveal();
330 $languageService->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears')
331 ->willReturn(
' min| hrs| days| yrs| min| hour| day| year');
332 $languageService->sL(Argument::cetera())->willReturnArgument(0);
336 $expected[
'recordTitle'] = $expectedTitle;
337 $this->assertSame($expected, $this->subject->addData($input));
346 'tableName' =>
'aTable',
350 'anotherField' =>
'anotherValue',
355 'label_alt' =>
'anotherField',
373 $expected[
'recordTitle'] =
'anotherValue';
374 $this->assertSame($expected, $this->subject->addData($input));
383 'tableName' =>
'aTable',
387 'anotherField' =>
'',
388 'additionalField' =>
'additionalValue'
393 'label_alt' =>
'anotherField,additionalField',
406 'additionalField' => [
416 $expected[
'recordTitle'] =
'additionalValue';
417 $this->assertSame($expected, $this->subject->addData($input));
426 'tableName' =>
'aTable',
429 'aField' =>
'aField',
430 'anotherField' =>
'anotherField'
435 'label_alt' =>
'anotherField',
436 'label_alt_force' =>
true,
454 $expected[
'recordTitle'] =
'aField, anotherField';
455 $this->assertSame($expected, $this->subject->addData($input));
464 'tableName' =>
'aTable',
467 'aField' =>
'aField',
468 'anotherField' =>
'anotherField',
469 'additionalField' =>
'additionalValue'
474 'label_alt' =>
'anotherField,additionalField',
475 'label_alt_force' =>
true,
488 'additionalField' => [
498 $expected[
'recordTitle'] =
'aField, anotherField, additionalValue';
499 $this->assertSame($expected, $this->subject->addData($input));
508 'tableName' =>
'aTable',
511 'aField' =>
'aField',
512 'anotherField' =>
'',
513 'additionalField' =>
'additionalValue'
518 'label_alt' =>
'anotherField,additionalField',
519 'label_alt_force' =>
true,
532 'additionalField' => [
542 $expected[
'recordTitle'] =
'aField, additionalValue';
543 $this->assertSame($expected, $this->subject->addData($input));
552 'tableName' =>
'aTable',
577 $expected[
'recordTitle'] =
'bar';
578 $this->assertSame($expected, $this->subject->addData($input));
595 'internal_type' =>
'db',
600 'internal_type: file' => [
602 'internal_type' =>
'file',
604 'somePath/aFile.jpg,someOtherPath/anotherFile.png',
605 'somePath/aFile.jpg, someOtherPath/anotherFile.png',
607 'internal_type: db, single table, single record' => [
609 'internal_type' =>
'db',
610 'allowed' =>
'aTable'
615 'internal_type: db, single table, multiple records' => [
617 'internal_type' =>
'db',
618 'allowed' =>
'aTable'
620 '1|aValue,3|anotherValue',
621 'aValue, anotherValue',
623 'internal_type: db, multiple tables, single record' => [
625 'internal_type' =>
'db',
626 'allowed' =>
'aTable,anotherTable'
628 'anotherTable_1|anotherValue',
631 'internal_type: db, multiple tables, multiple records' => [
633 'internal_type' =>
'db',
634 'allowed' =>
'aTable,anotherTable'
636 'anotherTable_1|anotherValue,aTable_1|aValue',
637 'aValue, anotherValue',
650 public function addDataReturnsRecordTitleForGroupType($fieldConfig, $fieldValue, $expectedTitle)
653 'tableName' =>
'aTable',
656 'aField' => $fieldValue,
664 'config' => array_merge(
676 $languageService = $this->prophesize(LanguageService::class);
677 $GLOBALS[
'LANG'] = $languageService->reveal();
678 $languageService->sL(Argument::cetera())->willReturnArgument(0);
681 $expected[
'recordTitle'] = $expectedTitle;
682 $this->assertSame($expected, $this->subject->addData($input));
691 'tableName' =>
'aTable',
694 'aField' =>
'aTable_1|aValue,anotherTable_2|anotherValue',
704 'internal_type' =>
'db',
705 'allowed' =>
'aTable,anotherTable',
713 $expected[
'recordTitle'] =
'aValue, anotherValue';
714 $this->assertSame($expected, $this->subject->addData($input));
720 public function addDataReturnsRecordTitleForSingleCheckboxType()
723 'tableName' =>
'aTable',
742 $languageService = $this->prophesize(LanguageService::class);
743 $GLOBALS[
'LANG'] = $languageService->reveal();
744 $languageService->sL(Argument::cetera())->willReturnArgument(0)->shouldBeCalled();
747 $expected[
'recordTitle'] =
'LLL:EXT:lang/locallang_common.xlf:yes';
748 $this->assertSame($expected, $this->subject->addData($input));
757 'tableName' =>
'aTable',
781 $expected[
'recordTitle'] =
'foo, baz';
782 $this->assertSame($expected, $this->subject->addData($input));
791 'tableName' =>
'aTable',
798 'vDEF' =>
'aFlexValue',
820 'label' =>
'Some input field',
838 $expected[
'recordTitle'] =
'';
839 $this->assertSame($expected, $this->subject->addData($input));
848 'tableName' =>
'aTable',
864 [
'foo', 1, null, null],
865 [
'bar', 2, null, null],
866 [
'baz', 4, null, null],
875 $expected[
'recordTitle'] =
'foo, bar';
876 $this->assertSame($expected, $this->subject->addData($input));
885 'tableName' =>
'aTable',
887 'aField' =>
'<p> text </p>',
904 $expected[
'recordTitle'] =
'text';
905 $this->assertSame($expected, $this->subject->addData($input));