17 use Prophecy\Argument;
18 use Prophecy\Prophecy\ObjectProphecy;
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
35 $this->timeZone = date_default_timezone_get();
36 date_default_timezone_set(
'UTC');
41 date_default_timezone_set($this->timeZone);
51 'tableName' =>
'aTable',
57 $this->expectException(\UnexpectedValueException::class);
58 $this->expectExceptionCode(1443706103);
68 'tableName' =>
'aTable',
70 'isInlineChild' =>
false,
74 'label_userFunc' =>
function (&$parameters) {
75 $parameters[
'title'] =
'Test';
83 $expected[
'recordTitle'] =
'Test';
85 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
94 'tableName' =>
'aTable',
98 'isInlineChild' =>
true,
99 'isOnSymmetricSide' =>
false,
100 'inlineParentConfig' => [
101 'foreign_label' =>
'aField',
106 'formattedLabel_userFunc' =>
function (&$parameters) {
107 $parameters[
'title'] =
'Test';
115 $expected[
'recordTitle'] =
'Test';
117 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
126 'tableName' =>
'aTable',
128 'aField' =>
'aValue',
133 'label_userFunc' =>
function (&$parameters) {
134 $parameters[
'title'] =
'Value that MUST NOT be used, otherwise the code is broken.';
145 'isInlineChild' =>
true,
146 'isOnSymmetricSide' =>
false,
147 'inlineParentConfig' => [
148 'foreign_label' =>
'aField',
152 $expected[
'recordTitle'] =
'aValue';
153 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
162 'tableName' =>
'aTable',
165 'aField' =>
'aValue',
170 'formattedLabel_userFunc' =>
function (&$parameters) {
171 $parameters[
'title'] =
'aFormattedLabel';
182 'isInlineChild' =>
true,
183 'isOnSymmetricSide' =>
false,
184 'inlineParentConfig' => [
185 'foreign_label' =>
'aField',
189 $expected[
'recordTitle'] =
'aFormattedLabel';
190 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
199 'tableName' =>
'aTable',
201 'aField' =>
'aValue',
215 'isInlineChild' =>
true,
216 'inlineParentConfig' => [
217 'symmetric_label' =>
'aField',
219 'isOnSymmetricSide' =>
true,
222 $expected[
'recordTitle'] =
'aValue';
223 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
232 'tableName' =>
'aTable',
233 'isInlineChild' =>
false,
235 'uid' =>
'NEW56017ee37d10e587251374',
246 $languageService = $this->prophesize(LanguageService::class);
247 $GLOBALS[
'LANG'] = $languageService->reveal();
248 $languageService->sL(Argument::cetera())->willReturnArgument(0);
251 $expected[
'recordTitle'] =
'NEW56017ee37d10e587251374';
252 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
274 'plain text input' => [
287 '01-01-01 (-7 days)',
289 'date input (dbType: date)' => [
296 '01-01-01 (-7 days)',
298 'date input (disableAgeDisplay: TRUE)' => [
302 'disableAgeDisplay' => true
315 'time input (dbType: time)' => [
332 'timesec input (dbType: time)' => [
341 'datetime input' => [
344 'eval' =>
'datetime',
350 'datetime input (dbType: datetime)' => [
353 'eval' =>
'datetime',
354 'dbType' =>
'datetime'
356 '2014-12-31 23:59:59',
373 'tableName' =>
'aTable',
374 'isInlineChild' =>
false,
377 'aField' => $fieldValue,
385 'config' => $fieldConfig,
392 $languageService = $this->prophesize(LanguageService::class);
393 $GLOBALS[
'LANG'] = $languageService->reveal();
394 $languageService->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.minutesHoursDaysYears')
395 ->willReturn(
' min| hrs| days| yrs| min| hour| day| year');
396 $languageService->sL(Argument::cetera())->willReturnArgument(0);
400 $expected[
'recordTitle'] = $expectedTitle;
401 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
410 'tableName' =>
'aTable',
411 'isInlineChild' =>
false,
415 'anotherField' =>
'anotherValue',
420 'label_alt' =>
'anotherField',
438 $expected[
'recordTitle'] =
'anotherValue';
439 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
448 'tableName' =>
'aTable',
449 'isInlineChild' =>
false,
453 'anotherField' =>
'',
454 'additionalField' =>
'additionalValue'
459 'label_alt' =>
'anotherField,additionalField',
472 'additionalField' => [
482 $expected[
'recordTitle'] =
'additionalValue';
483 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
492 'tableName' =>
'aTable',
493 'isInlineChild' =>
false,
496 'aField' =>
'aField',
497 'anotherField' =>
'anotherField'
502 'label_alt' =>
'anotherField',
503 'label_alt_force' =>
true,
521 $expected[
'recordTitle'] =
'aField, anotherField';
522 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
531 'tableName' =>
'aTable',
532 'isInlineChild' =>
false,
535 'aField' =>
'aField',
536 'anotherField' =>
'anotherField',
537 'additionalField' =>
'additionalValue'
542 'label_alt' =>
'anotherField,additionalField',
543 'label_alt_force' =>
true,
556 'additionalField' => [
566 $expected[
'recordTitle'] =
'aField, anotherField, additionalValue';
567 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
576 'tableName' =>
'aTable',
577 'isInlineChild' =>
false,
580 'aField' =>
'aField',
581 'anotherField' =>
'',
582 'additionalField' =>
'additionalValue'
587 'label_alt' =>
'anotherField,additionalField',
588 'label_alt_force' =>
true,
601 'additionalField' => [
611 $expected[
'recordTitle'] =
'aField, additionalValue';
612 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
621 'tableName' =>
'aTable',
622 'isInlineChild' =>
false,
647 $expected[
'recordTitle'] =
'bar';
648 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
657 'tableName' =>
'aTable',
658 'isInlineChild' =>
false,
674 'recordTitle' =>
'foo',
684 $expected[
'recordTitle'] =
'foo';
685 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
702 'internal_type' =>
'db',
707 'internal_type: file' => [
709 'internal_type' =>
'file',
713 'uidOrPath' =>
'somePath/aFile.jpg',
716 'uidOrPath' =>
'someOtherPath/anotherFile.png',
719 'somePath/aFile.jpg, someOtherPath/anotherFile.png',
721 'internal_type: db, single table, single record' => [
723 'internal_type' =>
'db',
724 'allowed' =>
'aTable'
733 'internal_type: db, single table, multiple records' => [
735 'internal_type' =>
'db',
736 'allowed' =>
'aTable'
743 'title' =>
'anotherValue',
746 'aValue, anotherValue',
748 'internal_type: db, multiple tables, single record' => [
750 'internal_type' =>
'db',
751 'allowed' =>
'aTable,anotherTable'
756 'table' =>
'anotherTable',
757 'title' =>
'anotherValue',
762 'internal_type: db, multiple tables, multiple records' => [
764 'internal_type' =>
'db',
765 'allowed' =>
'aTable,anotherTable'
775 'table' =>
'anotherTable',
776 'title' =>
'anotherValue',
779 'aValue, anotherValue',
795 'tableName' =>
'aTable',
796 'isInlineChild' =>
false,
799 'aField' => $fieldValue,
807 'config' => array_merge(
819 $languageService = $this->prophesize(LanguageService::class);
820 $GLOBALS[
'LANG'] = $languageService->reveal();
821 $languageService->sL(Argument::cetera())->willReturnArgument(0);
824 $expected[
'recordTitle'] = $expectedTitle;
825 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
834 'tableName' =>
'aTable',
835 'isInlineChild' =>
false,
846 'table' =>
'anotherTable',
847 'title' =>
'anotherValue',
859 'internal_type' =>
'db',
860 'allowed' =>
'aTable,anotherTable',
868 $expected[
'recordTitle'] =
'aValue, anotherValue';
869 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
878 'tableName' =>
'aTable',
879 'isInlineChild' =>
false,
898 $languageService = $this->prophesize(LanguageService::class);
899 $GLOBALS[
'LANG'] = $languageService->reveal();
900 $languageService->sL(Argument::cetera())->willReturnArgument(0)->shouldBeCalled();
903 $expected[
'recordTitle'] =
'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:yes';
904 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
913 'tableName' =>
'aTable',
914 'isInlineChild' =>
false,
938 $languageService = $this->prophesize(LanguageService::class);
939 $GLOBALS[
'LANG'] = $languageService->reveal();
940 $languageService->sL(Argument::cetera())->willReturnArgument(0);
943 $expected[
'recordTitle'] =
'foo, baz';
944 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
953 'tableName' =>
'aTable',
954 'isInlineChild' =>
false,
961 'vDEF' =>
'aFlexValue',
983 'label' =>
'Some input field',
1001 $expected[
'recordTitle'] =
'';
1002 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
1011 'tableName' =>
'aTable',
1012 'isInlineChild' =>
false,
1028 [
'foo', 1,
null,
null],
1029 [
'bar', 2,
null,
null],
1030 [
'baz', 4,
null,
null],
1039 $expected[
'recordTitle'] =
'foo, bar';
1040 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));
1049 'tableName' =>
'aTable',
1050 'isInlineChild' =>
false,
1052 'aField' =>
'<p> text </p>',
1056 'label' =>
'aField',
1069 $expected[
'recordTitle'] =
'text';
1070 $this->assertSame($expected, (
new TcaRecordTitle)->addData($input));