48a3aa708ac5206238e44faceb86a1890619ed37
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Tests / Unit / Form / FormDataProvider / TcaRecordTitleTest.php
1 <?php
2 namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use Prophecy\Argument;
18 use Prophecy\Prophecy\ObjectProphecy;
19 use TYPO3\CMS\Backend\Form\FormDataProvider\TcaRecordTitle;
20 use TYPO3\CMS\Core\Localization\LanguageService;
21
22 /**
23 * Test case
24 */
25 class TcaRecordTitleTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
26 {
27 /**
28 * Subject is not notice free, disable E_NOTICES
29 */
30 protected static $suppressNotices = true;
31
32 /**
33 * @var TcaRecordTitle
34 */
35 protected $subject;
36
37 /**
38 * @var string
39 */
40 protected $timeZone;
41
42 public function setUp()
43 {
44 $this->subject = new TcaRecordTitle();
45 $this->timeZone = date_default_timezone_get();
46 date_default_timezone_set('UTC');
47 }
48
49 protected function tearDown()
50 {
51 date_default_timezone_set($this->timeZone);
52 parent::tearDown();
53 }
54
55 /**
56 * @test
57 */
58 public function addDataThrowsExceptionWithMissingLabel()
59 {
60 $input = [
61 'tableName' => 'aTable',
62 'databaseRew' => [],
63 'processedTca' => [
64 'ctrl' => [],
65 ],
66 ];
67 $this->expectException(\UnexpectedValueException::class);
68 $this->expectExceptionCode(1443706103);
69 $this->subject->addData($input);
70 }
71
72 /**
73 * @test
74 */
75 public function addDataReturnsRecordTitleForLabelUserFunction()
76 {
77 $input = [
78 'tableName' => 'aTable',
79 'databaseRow' => [],
80 'processedTca' => [
81 'ctrl' => [
82 'label' => 'uid',
83 'label_userFunc' => function (&$parameters) {
84 $parameters['title'] = 'Test';
85 }
86 ],
87 'columns' => [],
88 ],
89 ];
90
91 $expected = $input;
92 $expected['recordTitle'] = 'Test';
93
94 $this->assertSame($expected, $this->subject->addData($input));
95 }
96
97 /**
98 * @test
99 */
100 public function addDataReturnsRecordTitleForFormattedLabelUserFunction()
101 {
102 $input = [
103 'tableName' => 'aTable',
104 'databaseRow' => [],
105 'isInlineChild' => true,
106 'processedTca' => [
107 'ctrl' => [
108 'label' => 'uid',
109 'formattedLabel_userFunc' => function (&$parameters) {
110 $parameters['title'] = 'Test';
111 }
112 ],
113 'columns' => [],
114 ],
115 ];
116
117 $expected = $input;
118 $expected['recordTitle'] = 'Test';
119
120 $this->assertSame($expected, $this->subject->addData($input));
121 }
122
123 /**
124 * @test
125 */
126 public function addDataReturnsRecordTitleForInlineChildWithForeignLabel()
127 {
128 $input = [
129 'tableName' => 'aTable',
130 'databaseRow' => [
131 'aField' => 'aValue',
132 ],
133 'processedTca' => [
134 'ctrl' => [
135 'label' => 'foo',
136 'label_userFunc' => function (&$parameters) {
137 $parameters['title'] = 'Value that MUST NOT be used, otherwise the code is broken.';
138 }
139 ],
140 'columns' => [
141 'aField' => [
142 'config' => [
143 'type' => 'input',
144 ],
145 ],
146 ],
147 ],
148 'isInlineChild' => true,
149 'inlineParentConfig' => [
150 'foreign_label' => 'aField',
151 ],
152 ];
153 $expected = $input;
154 $expected['recordTitle'] = 'aValue';
155 $this->assertSame($expected, $this->subject->addData($input));
156 }
157
158 /**
159 * @test
160 */
161 public function addDataOverridesRecordTitleWithFormattedLabelUserFuncForInlineChildWithForeignLabel()
162 {
163 $input = [
164 'tableName' => 'aTable',
165 'databaseRow' => [
166 'aField' => 'aValue',
167 ],
168 'processedTca' => [
169 'ctrl' => [
170 'label' => 'foo',
171 'formattedLabel_userFunc' => function (&$parameters) {
172 $parameters['title'] = 'aFormattedLabel';
173 },
174 ],
175 'columns' => [
176 'aField' => [
177 'config' => [
178 'type' => 'input',
179 ],
180 ],
181 ],
182 ],
183 'isInlineChild' => true,
184 'inlineParentConfig' => [
185 'foreign_label' => 'aField',
186 ],
187 ];
188 $expected = $input;
189 $expected['recordTitle'] = 'aFormattedLabel';
190 $this->assertSame($expected, $this->subject->addData($input));
191 }
192
193 /**
194 * @test
195 */
196 public function addDataReturnsRecordTitleForInlineChildWithSymmetricLabel()
197 {
198 $input = [
199 'tableName' => 'aTable',
200 'databaseRow' => [
201 'aField' => 'aValue',
202 ],
203 'processedTca' => [
204 'ctrl' => [
205 'label' => 'foo',
206 ],
207 'columns' => [
208 'aField' => [
209 'config' => [
210 'type' => 'input',
211 ],
212 ],
213 ],
214 ],
215 'isInlineChild' => true,
216 'inlineParentConfig' => [
217 'symmetric_label' => 'aField',
218 ],
219 'isOnSymmetricSide' => true,
220 ];
221 $expected = $input;
222 $expected['recordTitle'] = 'aValue';
223 $this->assertSame($expected, $this->subject->addData($input));
224 }
225
226 /**
227 * @test
228 */
229 public function addDataReturnsRecordTitleForUid()
230 {
231 $input = [
232 'tableName' => 'aTable',
233 'databaseRow' => [
234 'uid' => 'NEW56017ee37d10e587251374',
235 ],
236 'processedTca' => [
237 'ctrl' => [
238 'label' => 'uid'
239 ],
240 'columns' => [],
241 ]
242 ];
243
244 /** @var LanguageService|ObjectProphecy $languageService */
245 $languageService = $this->prophesize(LanguageService::class);
246 $GLOBALS['LANG'] = $languageService->reveal();
247 $languageService->sL(Argument::cetera())->willReturnArgument(0);
248
249 $expected = $input;
250 $expected['recordTitle'] = 'NEW56017ee37d10e587251374';
251 $this->assertSame($expected, $this->subject->addData($input));
252 }
253
254 /**
255 * Data provider for addDataReturnsRecordTitleForInputType
256 * Each data set is an array with the following elements:
257 * - TCA field ['config'] section
258 * - Database value for field
259 * - expected title to be generated
260 *
261 * @returns array
262 */
263 public function addDataReturnsRecordTitleForInputTypeDataProvider()
264 {
265 return [
266 'new record' => [
267 [
268 'type' => 'input',
269 ],
270 '',
271 '',
272 ],
273 'plain text input' => [
274 [
275 'type' => 'input',
276 ],
277 'aValue',
278 'aValue',
279 ],
280 'date input' => [
281 [
282 'type' => 'input',
283 'eval' => 'date'
284 ],
285 '978307261',
286 '01-01-01 (-7 days)',
287 ],
288 'date input (dbType: date)' => [
289 [
290 'type' => 'input',
291 'eval' => 'date',
292 'dbType' => 'date'
293 ],
294 '2001-01-01',
295 '01-01-01 (-7 days)',
296 ],
297 'date input (disableAgeDisplay: TRUE)' => [
298 [
299 'type' => 'input',
300 'eval' => 'date',
301 'disableAgeDisplay' => true
302 ],
303 '978307261',
304 '01-01-01',
305 ],
306 'time input' => [
307 [
308 'type' => 'input',
309 'eval' => 'time',
310 ],
311 '44100',
312 '12:15',
313 ],
314 'time input (dbType: time)' => [
315 [
316 'type' => 'input',
317 'eval' => 'time',
318 'dbType' => 'time'
319 ],
320 '23:59:00',
321 '23:59',
322 ],
323 'timesec input' => [
324 [
325 'type' => 'input',
326 'eval' => 'timesec',
327 ],
328 '44130',
329 '12:15:30',
330 ],
331 'timesec input (dbType: time)' => [
332 [
333 'type' => 'input',
334 'eval' => 'timesec',
335 'dbType' => 'time'
336 ],
337 '23:59:59',
338 '23:59:59',
339 ],
340 'datetime input' => [
341 [
342 'type' => 'input',
343 'eval' => 'datetime',
344 'dbType' => 'date'
345 ],
346 '978307261',
347 '01-01-01 00:01',
348 ],
349 'datetime input (dbType: datetime)' => [
350 [
351 'type' => 'input',
352 'eval' => 'datetime',
353 'dbType' => 'datetime'
354 ],
355 '2014-12-31 23:59:59',
356 '31-12-14 23:59',
357 ],
358 ];
359 }
360
361 /**
362 * @test
363 * @dataProvider addDataReturnsRecordTitleForInputTypeDataProvider
364 *
365 * @param array $fieldConfig
366 * @param string $fieldValue
367 * @param string $expectedTitle
368 */
369 public function addDataReturnsRecordTitleForInputType($fieldConfig, $fieldValue, $expectedTitle)
370 {
371 $input = [
372 'tableName' => 'aTable',
373 'databaseRow' => [
374 'uid' => '1',
375 'aField' => $fieldValue,
376 ],
377 'processedTca' => [
378 'ctrl' => [
379 'label' => 'aField'
380 ],
381 'columns' => [
382 'aField' => [
383 'config' => $fieldConfig,
384 ]
385 ],
386 ]
387 ];
388
389 /** @var LanguageService|ObjectProphecy $languageService */
390 $languageService = $this->prophesize(LanguageService::class);
391 $GLOBALS['LANG'] = $languageService->reveal();
392 $languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.minutesHoursDaysYears')
393 ->willReturn(' min| hrs| days| yrs| min| hour| day| year');
394 $languageService->sL(Argument::cetera())->willReturnArgument(0);
395 $GLOBALS['EXEC_TIME'] = 978912061;
396
397 $expected = $input;
398 $expected['recordTitle'] = $expectedTitle;
399 $this->assertSame($expected, $this->subject->addData($input));
400 }
401
402 /**
403 * @test
404 */
405 public function addDataReturnsRecordTitleWithAlternativeLabel()
406 {
407 $input = [
408 'tableName' => 'aTable',
409 'databaseRow' => [
410 'uid' => '1',
411 'aField' => '',
412 'anotherField' => 'anotherValue',
413 ],
414 'processedTca' => [
415 'ctrl' => [
416 'label' => 'aField',
417 'label_alt' => 'anotherField',
418 ],
419 'columns' => [
420 'aField' => [
421 'config' => [
422 'type' => 'input'
423 ]
424 ],
425 'anotherField' => [
426 'config' => [
427 'type' => 'input'
428 ]
429 ]
430 ],
431 ]
432 ];
433
434 $expected = $input;
435 $expected['recordTitle'] = 'anotherValue';
436 $this->assertSame($expected, $this->subject->addData($input));
437 }
438
439 /**
440 * @test
441 */
442 public function addDataReturnsRecordTitleWithMultipleAlternativeLabels()
443 {
444 $input = [
445 'tableName' => 'aTable',
446 'databaseRow' => [
447 'uid' => '1',
448 'aField' => '',
449 'anotherField' => '',
450 'additionalField' => 'additionalValue'
451 ],
452 'processedTca' => [
453 'ctrl' => [
454 'label' => 'aField',
455 'label_alt' => 'anotherField,additionalField',
456 ],
457 'columns' => [
458 'aField' => [
459 'config' => [
460 'type' => 'input'
461 ]
462 ],
463 'anotherField' => [
464 'config' => [
465 'type' => 'input'
466 ]
467 ],
468 'additionalField' => [
469 'config' => [
470 'type' => 'input'
471 ]
472 ],
473 ],
474 ]
475 ];
476
477 $expected = $input;
478 $expected['recordTitle'] = 'additionalValue';
479 $this->assertSame($expected, $this->subject->addData($input));
480 }
481
482 /**
483 * @test
484 */
485 public function addDataReturnsRecordTitleWithForcedAlternativeLabel()
486 {
487 $input = [
488 'tableName' => 'aTable',
489 'databaseRow' => [
490 'uid' => '1',
491 'aField' => 'aField',
492 'anotherField' => 'anotherField'
493 ],
494 'processedTca' => [
495 'ctrl' => [
496 'label' => 'aField',
497 'label_alt' => 'anotherField',
498 'label_alt_force' => true,
499 ],
500 'columns' => [
501 'aField' => [
502 'config' => [
503 'type' => 'input'
504 ]
505 ],
506 'anotherField' => [
507 'config' => [
508 'type' => 'input'
509 ]
510 ],
511 ],
512 ]
513 ];
514
515 $expected = $input;
516 $expected['recordTitle'] = 'aField, anotherField';
517 $this->assertSame($expected, $this->subject->addData($input));
518 }
519
520 /**
521 * @test
522 */
523 public function addDataReturnsRecordTitleWithMultipleForcedAlternativeLabels()
524 {
525 $input = [
526 'tableName' => 'aTable',
527 'databaseRow' => [
528 'uid' => '1',
529 'aField' => 'aField',
530 'anotherField' => 'anotherField',
531 'additionalField' => 'additionalValue'
532 ],
533 'processedTca' => [
534 'ctrl' => [
535 'label' => 'aField',
536 'label_alt' => 'anotherField,additionalField',
537 'label_alt_force' => true,
538 ],
539 'columns' => [
540 'aField' => [
541 'config' => [
542 'type' => 'input'
543 ]
544 ],
545 'anotherField' => [
546 'config' => [
547 'type' => 'input'
548 ]
549 ],
550 'additionalField' => [
551 'config' => [
552 'type' => 'input'
553 ]
554 ],
555 ],
556 ]
557 ];
558
559 $expected = $input;
560 $expected['recordTitle'] = 'aField, anotherField, additionalValue';
561 $this->assertSame($expected, $this->subject->addData($input));
562 }
563
564 /**
565 * @test
566 */
567 public function addDataReturnsRecordTitleIgnoresEmptyAlternativeLabels()
568 {
569 $input = [
570 'tableName' => 'aTable',
571 'databaseRow' => [
572 'uid' => '1',
573 'aField' => 'aField',
574 'anotherField' => '',
575 'additionalField' => 'additionalValue'
576 ],
577 'processedTca' => [
578 'ctrl' => [
579 'label' => 'aField',
580 'label_alt' => 'anotherField,additionalField',
581 'label_alt_force' => true,
582 ],
583 'columns' => [
584 'aField' => [
585 'config' => [
586 'type' => 'input'
587 ]
588 ],
589 'anotherField' => [
590 'config' => [
591 'type' => 'input'
592 ]
593 ],
594 'additionalField' => [
595 'config' => [
596 'type' => 'input'
597 ]
598 ],
599 ],
600 ]
601 ];
602
603 $expected = $input;
604 $expected['recordTitle'] = 'aField, additionalValue';
605 $this->assertSame($expected, $this->subject->addData($input));
606 }
607
608 /**
609 * @test
610 */
611 public function addDataReturnsRecordTitleForRadioType()
612 {
613 $input = [
614 'tableName' => 'aTable',
615 'databaseRow' => [
616 'uid' => '1',
617 'aField' => '2',
618 ],
619 'processedTca' => [
620 'ctrl' => [
621 'label' => 'aField'
622 ],
623 'columns' => [
624 'aField' => [
625 'config' => [
626 'type' => 'radio',
627 'items' => [
628 ['foo', 1],
629 ['bar', 2],
630 ['baz', 3],
631 ]
632 ]
633 ]
634 ],
635 ]
636 ];
637
638 $expected = $input;
639 $expected['recordTitle'] = 'bar';
640 $this->assertSame($expected, $this->subject->addData($input));
641 }
642
643 /**
644 * @test
645 */
646 public function addDataReturnsRecordTitleForInlineType()
647 {
648 $input = [
649 'tableName' => 'aTable',
650 'databaseRow' => [
651 'uid' => '1',
652 'aField' => '2',
653 ],
654 'processedTca' => [
655 'ctrl' => [
656 'label' => 'aField'
657 ],
658 'columns' => [
659 'aField' => [
660 'config' => [
661 'type' => 'inline'
662 ],
663 'children' => [
664 [
665 'recordTitle' => 'foo',
666 'vanillaUid' => 2
667 ]
668 ]
669 ]
670 ],
671 ]
672 ];
673
674 $expected = $input;
675 $expected['recordTitle'] = 'foo';
676 $this->assertSame($expected, $this->subject->addData($input));
677 }
678
679 /**
680 * Data provider for addDataReturnsRecordTitleForGroupType
681 * Each data set is an array with the following elements:
682 * - TCA field configuration (merged with base config)
683 * - Database value for field
684 * - expected title to be generated
685 *
686 * @returns array
687 */
688 public function addDataReturnsRecordTitleForGroupTypeDataProvider()
689 {
690 return [
691 'new record' => [
692 [
693 'internal_type' => 'db',
694 ],
695 [],
696 ''
697 ],
698 'internal_type: file' => [
699 [
700 'internal_type' => 'file',
701 ],
702 [
703 [
704 'uidOrPath' => 'somePath/aFile.jpg',
705 ],
706 [
707 'uidOrPath' => 'someOtherPath/anotherFile.png',
708 ],
709 ],
710 'somePath/aFile.jpg, someOtherPath/anotherFile.png',
711 ],
712 'internal_type: db, single table, single record' => [
713 [
714 'internal_type' => 'db',
715 'allowed' => 'aTable'
716 ],
717 [
718 [
719 'title' => 'aValue',
720 ],
721 ],
722 'aValue',
723 ],
724 'internal_type: db, single table, multiple records' => [
725 [
726 'internal_type' => 'db',
727 'allowed' => 'aTable'
728 ],
729 [
730 [
731 'title' => 'aValue',
732 ],
733 [
734 'title' => 'anotherValue',
735 ],
736 ],
737 'aValue, anotherValue',
738 ],
739 'internal_type: db, multiple tables, single record' => [
740 [
741 'internal_type' => 'db',
742 'allowed' => 'aTable,anotherTable'
743 ],
744 [
745 [
746 'uid' => 1,
747 'table' => 'anotherTable',
748 'title' => 'anotherValue',
749 ],
750 ],
751 'anotherValue',
752 ],
753 'internal_type: db, multiple tables, multiple records' => [
754 [
755 'internal_type' => 'db',
756 'allowed' => 'aTable,anotherTable'
757 ],
758 [
759 [
760 'uid' => 1,
761 'table' => 'aTable',
762 'title' => 'aValue',
763 ],
764 [
765 'uid' => 2,
766 'table' => 'anotherTable',
767 'title' => 'anotherValue',
768 ],
769 ],
770 'aValue, anotherValue',
771 ],
772 ];
773 }
774
775 /**
776 * @test
777 * @dataProvider addDataReturnsRecordTitleForGroupTypeDataProvider
778 *
779 * @param array $fieldConfig
780 * @param string $fieldValue
781 * @param string $expectedTitle
782 */
783 public function addDataReturnsRecordTitleForGroupType($fieldConfig, $fieldValue, $expectedTitle)
784 {
785 $input = [
786 'tableName' => 'aTable',
787 'databaseRow' => [
788 'uid' => '1',
789 'aField' => $fieldValue,
790 ],
791 'processedTca' => [
792 'ctrl' => [
793 'label' => 'aField'
794 ],
795 'columns' => [
796 'aField' => [
797 'config' => array_merge(
798 [
799 'type' => 'group',
800 ],
801 $fieldConfig
802 ),
803 ]
804 ],
805 ]
806 ];
807
808 /** @var LanguageService|ObjectProphecy $languageService */
809 $languageService = $this->prophesize(LanguageService::class);
810 $GLOBALS['LANG'] = $languageService->reveal();
811 $languageService->sL(Argument::cetera())->willReturnArgument(0);
812
813 $expected = $input;
814 $expected['recordTitle'] = $expectedTitle;
815 $this->assertSame($expected, $this->subject->addData($input));
816 }
817
818 /**
819 * @test
820 */
821 public function addDataReturnsRecordTitleForGroupTypeWithInternalTypeDb()
822 {
823 $input = [
824 'tableName' => 'aTable',
825 'databaseRow' => [
826 'uid' => '1',
827 'aField' => [
828 [
829 'uid' => 1,
830 'table' => 'aTable',
831 'title' => 'aValue',
832 ],
833 [
834 'uid' => 2,
835 'table' => 'anotherTable',
836 'title' => 'anotherValue',
837 ],
838 ],
839 ],
840 'processedTca' => [
841 'ctrl' => [
842 'label' => 'aField'
843 ],
844 'columns' => [
845 'aField' => [
846 'config' => [
847 'type' => 'group',
848 'internal_type' => 'db',
849 'allowed' => 'aTable,anotherTable',
850 ]
851 ]
852 ],
853 ]
854 ];
855
856 $expected = $input;
857 $expected['recordTitle'] = 'aValue, anotherValue';
858 $this->assertSame($expected, $this->subject->addData($input));
859 }
860
861 /**
862 * @test
863 */
864 public function addDataReturnsRecordTitleForSingleCheckboxType()
865 {
866 $input = [
867 'tableName' => 'aTable',
868 'databaseRow' => [
869 'aField' => 1,
870 ],
871 'processedTca' => [
872 'ctrl' => [
873 'label' => 'aField'
874 ],
875 'columns' => [
876 'aField' => [
877 'config' => [
878 'type' => 'check',
879 ]
880 ]
881 ],
882 ]
883 ];
884
885 /** @var LanguageService|ObjectProphecy $languageService */
886 $languageService = $this->prophesize(LanguageService::class);
887 $GLOBALS['LANG'] = $languageService->reveal();
888 $languageService->sL(Argument::cetera())->willReturnArgument(0)->shouldBeCalled();
889
890 $expected = $input;
891 $expected['recordTitle'] = 'LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:yes';
892 $this->assertSame($expected, $this->subject->addData($input));
893 }
894
895 /**
896 * @test
897 */
898 public function addDataReturnsRecordTitleForArrayCheckboxType()
899 {
900 $input = [
901 'tableName' => 'aTable',
902 'databaseRow' => [
903 'aField' => '5'
904 ],
905 'processedTca' => [
906 'ctrl' => [
907 'label' => 'aField'
908 ],
909 'columns' => [
910 'aField' => [
911 'config' => [
912 'type' => 'check',
913 'items' => [
914 ['foo', ''],
915 ['bar', ''],
916 ['baz', ''],
917 ]
918 ]
919 ]
920 ],
921 ]
922 ];
923
924 $expected = $input;
925 $expected['recordTitle'] = 'foo, baz';
926 $this->assertSame($expected, $this->subject->addData($input));
927 }
928
929 /**
930 * @test
931 */
932 public function addDataReturnsEmptyRecordTitleForFlexType()
933 {
934 $input = [
935 'tableName' => 'aTable',
936 'databaseRow' => [
937 'aField' => [
938 'data' => [
939 'sDEF' => [
940 'lDEF' => [
941 'aFlexField' => [
942 'vDEF' => 'aFlexValue',
943 ]
944 ]
945 ]
946 ]
947 ]
948 ],
949 'processedTca' => [
950 'ctrl' => [
951 'label' => 'aField'
952 ],
953 'columns' => [
954 'aField' => [
955 'config' => [
956 'type' => 'flex',
957 'ds' => [
958 'sheets' => [
959 'sDEF' => [
960 'ROOT' => [
961 'type' => 'array',
962 'el' => [
963 'aFlexField' => [
964 'label' => 'Some input field',
965 'config' => [
966 'type' => 'input',
967 ],
968 ],
969 ],
970 ],
971 ],
972 ],
973 ]
974
975 ]
976 ]
977 ],
978 ]
979 ];
980
981 $expected = $input;
982 $expected['recordTitle'] = '';
983 $this->assertSame($expected, $this->subject->addData($input));
984 }
985
986 /**
987 * @test
988 */
989 public function addDataReturnsRecordTitleForSelectType()
990 {
991 $input = [
992 'tableName' => 'aTable',
993 'databaseRow' => [
994 'aField' => [
995 '1',
996 '2'
997 ]
998 ],
999 'processedTca' => [
1000 'ctrl' => [
1001 'label' => 'aField'
1002 ],
1003 'columns' => [
1004 'aField' => [
1005 'config' => [
1006 'type' => 'select',
1007 'items' => [
1008 ['foo', 1, null, null],
1009 ['bar', 2, null, null],
1010 ['baz', 4, null, null],
1011 ]
1012 ]
1013 ]
1014 ],
1015 ]
1016 ];
1017
1018 $expected = $input;
1019 $expected['recordTitle'] = 'foo, bar';
1020 $this->assertSame($expected, $this->subject->addData($input));
1021 }
1022
1023 /**
1024 * @test
1025 */
1026 public function addDataReturnsStrippedAndTrimmedValueForTextType()
1027 {
1028 $input = [
1029 'tableName' => 'aTable',
1030 'databaseRow' => [
1031 'aField' => '<p> text </p>',
1032 ],
1033 'processedTca' => [
1034 'ctrl' => [
1035 'label' => 'aField',
1036 ],
1037 'columns' => [
1038 'aField' => [
1039 'config' => [
1040 'type' => 'text',
1041 ],
1042 ],
1043 ],
1044 ],
1045 ];
1046
1047 $expected = $input;
1048 $expected['recordTitle'] = 'text';
1049 $this->assertSame($expected, $this->subject->addData($input));
1050 }
1051 }