2 namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
17 use Prophecy\Argument;
18 use Prophecy\Prophecy\ObjectProphecy;
23 use TYPO3\CMS\Core\Tests\UnitTestCase;
93 $languageService = $this->prophesize(LanguageService::class);
94 $GLOBALS[
'LANG'] = $languageService->reveal();
95 $languageService->sL(Argument::cetera())->willReturnArgument(0);
98 $this->assertSame($expected, $this->subject->addData($input));
112 'renderType' =>
'selectSingle',
122 $this->setExpectedException(\UnexpectedValueException::class, $this->anything(), 1439288036);
124 $this->subject->addData($input);
130 public function addDataTranslatesItemLabels()
134 'aField' =>
'aValue',
141 'renderType' =>
'selectSingle',
156 $languageService = $this->prophesize(LanguageService::class);
157 $GLOBALS[
'LANG'] = $languageService->reveal();
158 $languageService->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue')->willReturn(
'INVALID VALUE "%s"');
160 $languageService->sL(
'aLabel')->shouldBeCalled()->willReturn(
'translated');
163 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'items'][0][0] =
'translated';
164 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'items'][0][2] = null;
165 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'items'][0][3] = null;
167 $expected[
'databaseRow'][
'aField'] = [
'aValue'];
169 $this->assertSame($expected, $this->subject->addData($input));
175 public function addDataKeepsIconFromItem()
179 'aField' =>
'aValue',
186 'renderType' =>
'selectSingle',
191 2 =>
'an-icon-reference',
203 $languageService = $this->prophesize(LanguageService::class);
204 $GLOBALS[
'LANG'] = $languageService->reveal();
205 $languageService->sL(Argument::cetera())->willReturnArgument(0);
208 $expected[
'databaseRow'][
'aField'] = [
'aValue'];
210 $this->assertSame($expected, $this->subject->addData($input));
219 'tableName' =>
'aTable',
225 'renderType' =>
'selectSingle',
226 'special' =>
'anUnknownValue',
233 $this->setExpectedException(\UnexpectedValueException::class, $this->anything(), 1439298496);
235 $this->subject->addData($input);
241 public function addDataAddsTablesWithSpecialTables()
247 'tableName' =>
'aTable',
253 'renderType' =>
'selectSingle',
254 'special' =>
'tables',
273 $GLOBALS[
'TCA_DESCR'][
'aTable'][
'columns'][
''][
'description'] =
'aDescription';
276 $languageService = $this->prophesize(LanguageService::class);
277 $GLOBALS[
'LANG'] = $languageService->reveal();
278 $languageService->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue')->willReturn(
'INVALID VALUE "%s"');
279 $languageService->sL(Argument::containingString(
'INVALID VALUE'))->willReturnArgument(0);
281 $languageService->sL(
'aTitle')->shouldBeCalled()->willReturnArgument(0);
282 $languageService->loadSingleTableDescription(
'aTable')->shouldBeCalled();
285 $expected[
'databaseRow'][
'aField'] = [];
286 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'items'] = [
290 2 =>
'default-not-found',
292 'description' =>
'aDescription',
297 $this->assertSame($expected, $this->subject->addData($input));
303 public function addDataAddsTablesWithSpecialPageTypes()
307 'aField' =>
'aValue',
309 'tableName' =>
'aTable',
315 'renderType' =>
'selectSingle',
316 'special' =>
'pagetypes',
342 $languageService = $this->prophesize(LanguageService::class);
343 $GLOBALS[
'LANG'] = $languageService->reveal();
344 $languageService->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue')->willReturn(
'INVALID VALUE "%s"');
346 $languageService->sL(
'aLabel')->shouldBeCalled()->willReturnArgument(0);
349 $expected[
'databaseRow'][
'aField'] = [
'aValue'];
350 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'items'] = [
354 2 =>
'default-not-found',
359 $this->assertSame($expected, $this->subject->addData($input));
368 'Table with exclude and non exclude field returns exclude item' => [
373 'title' =>
'fooTableTitle',
377 'label' =>
'barColumnTitle',
381 'label' =>
'bazColumnTitle',
389 0 =>
'fooTableTitle',
391 2 =>
'default-not-found',
395 0 =>
'barColumnTitle (bar)',
402 'Root level table with ignored root level restriction returns exclude item' => [
407 'title' =>
'fooTableTitle',
410 'ignoreRootLevelRestriction' =>
true,
415 'label' =>
'barColumnTitle',
424 0 =>
'fooTableTitle',
426 2 =>
'default-not-found',
430 0 =>
'barColumnTitle (bar)',
437 'Root level table without ignored root level restriction returns no item' => [
442 'title' =>
'fooTableTitle',
447 'label' =>
'barColumnTitle',
457 'Admin table returns no item' => [
462 'title' =>
'fooTableTitle',
467 'label' =>
'barColumnTitle',
484 public function addDataAddsExcludeFieldsWithSpecialExclude(
$tca, $expectedItems)
487 'tableName' =>
'aTable',
494 'renderType' =>
'selectSingle',
495 'special' =>
'exclude',
504 $languageService = $this->prophesize(LanguageService::class);
505 $GLOBALS[
'LANG'] = $languageService->reveal();
506 $languageService->loadSingleTableDescription(Argument::cetera())->willReturn(null);
507 $languageService->sL(Argument::cetera())->willReturnArgument(0);
509 $result = $this->subject->addData($input);
511 $this->assertSame($expectedItems, $result[
'processedTca'][
'columns'][
'aField'][
'config'][
'items']);
517 public function addDataAddsExcludeFieldsFromFlexWithSpecialExclude()
520 'tableName' =>
'aTable',
527 'renderType' =>
'selectSingle',
528 'special' =>
'exclude',
538 'title' =>
'fooTableTitle',
542 'label' =>
'aFlexFieldTitle',
554 <label>flexInputLabel</label>
574 $languageService = $this->prophesize(LanguageService::class);
575 $GLOBALS[
'LANG'] = $languageService->reveal();
576 $languageService->loadSingleTableDescription(Argument::cetera())->willReturn(null);
577 $languageService->sL(Argument::cetera())->willReturnArgument(0);
581 $database = $this->prophesize(DatabaseConnection::class);
582 $GLOBALS[
'TYPO3_DB'] = $database->reveal();
586 0 =>
'fooTableTitle aFlexFieldTitle dummy',
588 2 =>
'default-not-found',
592 0 =>
'flexInputLabel (input1)',
593 1 =>
'fooTable:aFlexField;dummy;sDEF;input1',
599 $result = $this->subject->addData($input);
601 $this->assertSame($expectedItems, $result[
'processedTca'][
'columns'][
'aField'][
'config'][
'items']);
607 public function addDataAddsExplicitAllowFieldsWithSpecialExplicitValues()
610 'tableName' =>
'aTable',
617 'renderType' =>
'selectSingle',
618 'special' =>
'explicitValues',
628 'title' =>
'fooTableTitle',
632 'label' =>
'aFieldTitle',
635 'renderType' =>
'selectSingle',
636 'authMode' =>
'explicitAllow',
650 $languageService = $this->prophesize(LanguageService::class);
651 $GLOBALS[
'LANG'] = $languageService->reveal();
652 $languageService->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.allow')->shouldBeCalled()->willReturn(
'allowMe');
653 $languageService->sL(Argument::cetera())->willReturnArgument(0);
657 0 =>
'fooTableTitle: aFieldTitle',
663 0 =>
'[allowMe] anItemTitle',
664 1 =>
'fooTable:aField:anItemValue:ALLOW',
665 2 =>
'status-status-permission-granted',
670 $result = $this->subject->addData($input);
672 $this->assertSame($expectedItems, $result[
'processedTca'][
'columns'][
'aField'][
'config'][
'items']);
678 public function addDataAddsExplicitDenyFieldsWithSpecialExplicitValues()
681 'tableName' =>
'aTable',
688 'renderType' =>
'selectSingle',
689 'special' =>
'explicitValues',
699 'title' =>
'fooTableTitle',
703 'label' =>
'aFieldTitle',
706 'renderType' =>
'selectSingle',
707 'authMode' =>
'explicitDeny',
721 $languageService = $this->prophesize(LanguageService::class);
722 $GLOBALS[
'LANG'] = $languageService->reveal();
723 $languageService->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.deny')->shouldBeCalled()->willReturn(
'denyMe');
724 $languageService->sL(Argument::cetera())->willReturnArgument(0);
728 0 =>
'fooTableTitle: aFieldTitle',
734 0 =>
'[denyMe] anItemTitle',
735 1 =>
'fooTable:aField:anItemValue:DENY',
736 2 =>
'status-status-permission-denied',
741 $result = $this->subject->addData($input);
743 $this->assertSame($expectedItems, $result[
'processedTca'][
'columns'][
'aField'][
'config'][
'items']);
749 public function addDataAddsExplicitIndividualAllowFieldsWithSpecialExplicitValues()
752 'tableName' =>
'aTable',
759 'renderType' =>
'selectSingle',
760 'special' =>
'explicitValues',
770 'title' =>
'fooTableTitle',
774 'label' =>
'aFieldTitle',
777 'renderType' =>
'selectSingle',
778 'authMode' =>
'individual',
807 $languageService = $this->prophesize(LanguageService::class);
808 $GLOBALS[
'LANG'] = $languageService->reveal();
809 $languageService->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.allow')->shouldBeCalled()->willReturn(
'allowMe');
810 $languageService->sL(Argument::cetera())->willReturnArgument(0);
814 0 =>
'fooTableTitle: aFieldTitle',
820 0 =>
'[allowMe] aItemTitle',
821 1 =>
'fooTable:aField:aItemValue:ALLOW',
822 2 =>
'status-status-permission-granted',
826 0 =>
'[allowMe] cItemTitle',
827 1 =>
'fooTable:aField:cItemValue:ALLOW',
828 2 =>
'status-status-permission-granted',
833 $result = $this->subject->addData($input);
835 $this->assertSame($expectedItems, $result[
'processedTca'][
'columns'][
'aField'][
'config'][
'items']);
841 public function addDataAddsExplicitIndividualDenyFieldsWithSpecialExplicitValues()
844 'tableName' =>
'aTable',
851 'renderType' =>
'selectSingle',
852 'special' =>
'explicitValues',
862 'title' =>
'fooTableTitle',
866 'label' =>
'aFieldTitle',
869 'renderType' =>
'selectSingle',
870 'authMode' =>
'individual',
899 $languageService = $this->prophesize(LanguageService::class);
900 $GLOBALS[
'LANG'] = $languageService->reveal();
901 $languageService->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.deny')->shouldBeCalled()->willReturn(
'denyMe');
902 $languageService->sL(Argument::cetera())->willReturnArgument(0);
906 0 =>
'fooTableTitle: aFieldTitle',
912 0 =>
'[denyMe] aItemTitle',
913 1 =>
'fooTable:aField:aItemValue:DENY',
914 2 =>
'status-status-permission-denied',
918 0 =>
'[denyMe] cItemTitle',
919 1 =>
'fooTable:aField:cItemValue:DENY',
920 2 =>
'status-status-permission-denied',
925 $result = $this->subject->addData($input);
927 $this->assertSame($expectedItems, $result[
'processedTca'][
'columns'][
'aField'][
'config'][
'items']);
933 public function addDataAddsLanguagesWithSpecialLanguages()
936 'tableName' =>
'aTable',
943 'renderType' =>
'selectSingle',
944 'special' =>
'languages',
949 'systemLanguageRows' => [
951 'title' =>
'aLangTitle',
953 'flagIconIdentifier' =>
'aFlag.gif',
959 $languageService = $this->prophesize(LanguageService::class);
960 $GLOBALS[
'LANG'] = $languageService->reveal();
961 $languageService->sL(Argument::cetera())->willReturnArgument(0);
965 0 =>
'aLangTitle [42]',
972 $result = $this->subject->addData($input);
974 $this->assertSame($expectedItems, $result[
'processedTca'][
'columns'][
'aField'][
'config'][
'items']);
980 public function addDataAddsCustomOptionsWithSpecialCustom()
983 'tableName' =>
'aTable',
990 'renderType' =>
'selectSingle',
991 'special' =>
'custom',
999 $languageService = $this->prophesize(LanguageService::class);
1000 $GLOBALS[
'LANG'] = $languageService->reveal();
1001 $languageService->sL(Argument::cetera())->willReturnArgument(0);
1003 $GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'customPermOptions'] = [
1005 'header' =>
'aHeader',
1023 1 =>
'aKey:anItemKey',
1029 $result = $this->subject->addData($input);
1031 $this->assertSame($expectedItems, $result[
'processedTca'][
'columns'][
'aField'][
'config'][
'items']);
1037 public function addDataAddsGroupItemsWithSpecialModListGroup()
1040 'tableName' =>
'aTable',
1041 'databaseRow' => [],
1047 'renderType' =>
'selectSingle',
1048 'special' =>
'modListGroup',
1058 $languageService = $this->prophesize(LanguageService::class);
1059 $GLOBALS[
'LANG'] = $languageService->reveal();
1060 $languageService->sL(Argument::cetera())->willReturnArgument(0);
1061 $languageService->moduleLabels = [
1063 'aModule_tab' => PATH_site .
'aModuleTabIcon.gif',
1066 'aModule_tablabel' =>
'aModuleTabLabel',
1067 'aModule_tabdescr' =>
'aModuleTabDescription',
1070 'aModule_tab' =>
'aModuleLabel',
1075 $moduleLoaderProphecy = $this->prophesize(ModuleLoader::class);
1077 $moduleLoaderProphecy->load([])->shouldBeCalled();
1078 $moduleLoaderProphecy->modListGroup = [
1084 0 =>
'aModuleLabel',
1086 2 =>
'../aModuleTabIcon.gif',
1088 'title' =>
'aModuleTabLabel',
1089 'description' =>
'aModuleTabDescription',
1094 $result = $this->subject->addData($input);
1096 $this->assertSame($expectedItems, $result[
'processedTca'][
'columns'][
'aField'][
'config'][
'items']);
1102 public function addDataAddsFileItemsWithConfiguredFileFolder()
1104 $directory = $this->getUniqueId(
'typo3temp/test-') .
'/';
1106 'tableName' =>
'aTable',
1107 'databaseRow' => [],
1113 'renderType' =>
'selectSingle',
1114 'fileFolder' => $directory,
1115 'fileFolder_extList' =>
'gif',
1116 'fileFolder_recursions' => 1,
1124 $languageService = $this->prophesize(LanguageService::class);
1125 $GLOBALS[
'LANG'] = $languageService->reveal();
1126 $languageService->sL(Argument::cetera())->willReturnArgument(0);
1128 mkdir(PATH_site . $directory);
1129 $this->testFilesToDelete[] = PATH_site . $directory;
1130 touch(PATH_site . $directory .
'anImage.gif');
1131 touch(PATH_site . $directory .
'aFile.txt');
1132 mkdir(PATH_site . $directory .
'/subdir');
1133 touch(PATH_site . $directory .
'/subdir/anotherImage.gif');
1139 2 =>
'../' . $directory .
'anImage.gif',
1143 0 =>
'subdir/anotherImage.gif',
1144 1 =>
'subdir/anotherImage.gif',
1145 2 =>
'../' . $directory .
'subdir/anotherImage.gif',
1150 $result = $this->subject->addData($input);
1152 $this->assertSame($expectedItems, $result[
'processedTca'][
'columns'][
'aField'][
'config'][
'items']);
1158 public function addDataAddsItemsByAddItemsFromPageTsConfig()
1164 'tableName' =>
'aTable',
1170 'renderType' =>
'selectSingle',
1198 $languageService = $this->prophesize(LanguageService::class);
1199 $GLOBALS[
'LANG'] = $languageService->reveal();
1200 $languageService->sL(Argument::cetera())->willReturnArgument(0);
1203 $expected[
'databaseRow'][
'aField'] = [];
1204 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'items'][1] = [
1211 $this->assertEquals($expected, $this->subject->addData($input));
1217 public function addDataAddsItemsByAddItemsWithDuplicateValuesFromPageTsConfig()
1223 'tableName' =>
'aTable',
1229 'renderType' =>
'selectSingle',
1257 $languageService = $this->prophesize(LanguageService::class);
1258 $GLOBALS[
'LANG'] = $languageService->reveal();
1259 $languageService->sL(Argument::cetera())->willReturnArgument(0);
1262 $expected[
'databaseRow'][
'aField'] = [];
1263 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'items'][1] = [
1270 $this->assertEquals($expected, $this->subject->addData($input));
1279 'replace REC_FIELD' => [
1280 'AND fTable.title=\'###REC_FIELD_rowField###\'',
1281 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.title=\'rowFieldValue\'',
1284 'replace REC_FIELD fullQuote' => [
1285 'AND fTable.title=###REC_FIELD_rowField###',
1286 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.title=\'rowFieldValue\'',
1289 'replace REC_FIELD fullQuoteWithArray' => [
1290 'AND fTable.title=###REC_FIELD_rowFieldThree###',
1291 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.title=\'rowFieldThreeValue\'',
1294 'rowFieldThree' => [
1295 0 =>
'rowFieldThreeValue'
1300 'replace REC_FIELD multiple markers' => [
1301 'AND fTable.title=\'###REC_FIELD_rowField###\' AND fTable.pid=###REC_FIELD_rowFieldTwo###',
1302 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.title=\'rowFieldValue\' AND fTable.pid=\'rowFieldTwoValue\'',
1305 'replace CURRENT_PID' => [
1306 'AND fTable.uid=###CURRENT_PID###',
1307 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.uid=43',
1310 'replace CURRENT_PID integer cast' => [
1311 'AND fTable.uid=###CURRENT_PID###',
1312 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.uid=431',
1314 'effectivePid' =>
'431string',
1317 'replace THIS_UID' => [
1318 'AND fTable.uid=###THIS_UID###',
1319 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.uid=42',
1322 'replace THIS_UID integer cast' => [
1323 'AND fTable.uid=###THIS_UID###',
1324 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.uid=421',
1327 'uid' =>
'421string',
1331 'replace SITEROOT' => [
1332 'AND fTable.uid=###SITEROOT###',
1333 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.uid=44',
1336 'replace SITEROOT integer cast' => [
1337 'AND fTable.uid=###SITEROOT###',
1338 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.uid=441',
1342 'uid' =>
'441string',
1347 'replace PAGE_TSCONFIG_ID' => [
1348 'AND fTable.uid=###PAGE_TSCONFIG_ID###',
1349 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.uid=45',
1352 'replace PAGE_TSCONFIG_ID integer cast' => [
1353 'AND fTable.uid=###PAGE_TSCONFIG_ID###',
1354 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.uid=451',
1360 'PAGE_TSCONFIG_ID' =>
'451string'
1367 'replace PAGE_TSCONFIG_STR' => [
1368 'AND fTable.uid=\'###PAGE_TSCONFIG_STR###\'',
1369 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.uid=\'46\'',
1372 'replace PAGE_TSCONFIG_IDLIST' => [
1373 'AND fTable.uid IN (###PAGE_TSCONFIG_IDLIST###)',
1374 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.uid IN (47,48)',
1377 'replace PAGE_TSCONFIG_IDLIST cleans list' => [
1378 'AND fTable.uid IN (###PAGE_TSCONFIG_IDLIST###)',
1379 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.uid IN (471,481)',
1385 'PAGE_TSCONFIG_IDLIST' =>
'a, 471, b, 481, c',
1399 public function addDataReplacesMarkersInForeignTableClause($foreignTableWhere, $expectedWhere, array $inputOverride)
1402 'tableName' =>
'aTable',
1403 'effectivePid' => 43,
1406 'rowField' =>
'rowFieldValue',
1407 'rowFieldTwo' =>
'rowFieldTwoValue',
1414 'renderType' =>
'selectSingle',
1415 'foreign_table' =>
'fTable',
1416 'foreign_table_where' => $foreignTableWhere,
1432 'is_siteroot' => null,
1439 'PAGE_TSCONFIG_ID' => 45,
1440 'PAGE_TSCONFIG_STR' =>
'46',
1441 'PAGE_TSCONFIG_IDLIST' =>
'47, 48',
1451 $expectedQueryArray = [
1452 'SELECT' =>
'fTable.uid',
1453 'FROM' =>
'fTable, pages',
1454 'WHERE' => $expectedWhere,
1461 $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
1462 $GLOBALS[
'BE_USER'] = $backendUserProphecy->reveal();
1463 $backendUserProphecy->getPagePermsClause(1)->shouldBeCalled()->willReturn(
' 1=1');
1466 $databaseProphecy = $this->prophesize(DatabaseConnection::class);
1467 $GLOBALS[
'TYPO3_DB'] = $databaseProphecy->reveal();
1468 $databaseProphecy->sql_error()->shouldBeCalled()->willReturn(
false);
1469 $databaseProphecy->quoteStr(Argument::cetera())->willReturnArgument(0);
1470 $databaseProphecy->fullQuoteStr(Argument::cetera())->will(
function ($args) {
1471 return '\'' . $args[0] .
'\'';
1473 $databaseProphecy->sql_fetch_assoc(Argument::cetera())->shouldBeCalled()->willReturn(
false);
1474 $databaseProphecy->sql_free_result(Argument::cetera())->shouldBeCalled()->willReturn(null);
1476 $databaseProphecy->exec_SELECT_queryArray($expectedQueryArray)->shouldBeCalled()->willReturn(
false);
1478 $this->subject->addData($input);
1487 'tableName' =>
'aTable',
1493 'renderType' =>
'selectSingle',
1494 'foreign_table' =>
'fTable',
1501 $this->setExpectedException(\UnexpectedValueException::class, $this->anything(), 1439569743);
1503 $this->subject->addData($input);
1509 public function addDataForeignTableSplitsGroupOrderAndLimit()
1512 'tableName' =>
'aTable',
1513 'databaseRow' => [],
1519 'renderType' =>
'selectSingle',
1520 'foreign_table' =>
'fTable',
1521 'foreign_table_where' =>
'AND ftable.uid=1 GROUP BY groupField ORDER BY orderField LIMIT 1,2',
1531 $expectedQueryArray = [
1532 'SELECT' =>
'fTable.uid',
1533 'FROM' =>
'fTable, pages',
1534 'WHERE' =>
'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND ftable.uid=1',
1535 'GROUPBY' =>
'groupField',
1536 'ORDERBY' =>
'orderField',
1541 $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
1542 $GLOBALS[
'BE_USER'] = $backendUserProphecy->reveal();
1543 $backendUserProphecy->getPagePermsClause(1)->shouldBeCalled()->willReturn(
' 1=1');
1546 $databaseProphecy = $this->prophesize(DatabaseConnection::class);
1547 $GLOBALS[
'TYPO3_DB'] = $databaseProphecy->reveal();
1548 $databaseProphecy->sql_error()->shouldBeCalled()->willReturn(
false);
1549 $databaseProphecy->quoteStr(Argument::cetera())->willReturnArgument(0);
1550 $databaseProphecy->fullQuoteStr(Argument::cetera())->will(
function ($args) {
1551 return '\'' . $args[0] .
'\'';
1553 $databaseProphecy->sql_fetch_assoc(Argument::cetera())->shouldBeCalled()->willReturn(
false);
1554 $databaseProphecy->sql_free_result(Argument::cetera())->shouldBeCalled()->willReturn(null);
1556 $databaseProphecy->exec_SELECT_queryArray($expectedQueryArray)->shouldBeCalled()->willReturn(
false);
1558 $this->subject->addData($input);
1564 public function addDataForeignTableQueuesFlashMessageOnDatabaseError()
1570 'tableName' =>
'aTable',
1576 'renderType' =>
'selectSingle',
1577 'foreign_table' =>
'fTable',
1597 $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
1598 $GLOBALS[
'BE_USER'] = $backendUserProphecy->reveal();
1599 $backendUserProphecy->getPagePermsClause(1)->shouldBeCalled()->willReturn(
' 1=1');
1602 $languageServiceProphecy = $this->prophesize(LanguageService::class);
1603 $GLOBALS[
'LANG'] = $languageServiceProphecy->reveal();
1604 $languageServiceProphecy->sL(Argument::cetera())->willReturnArgument(0);
1607 $databaseProphecy = $this->prophesize(DatabaseConnection::class);
1608 $GLOBALS[
'TYPO3_DB'] = $databaseProphecy->reveal();
1609 $databaseProphecy->exec_SELECT_queryArray(Argument::cetera())->willReturn(
false);
1611 $databaseProphecy->sql_error()->shouldBeCalled()->willReturn(
'anError');
1612 $databaseProphecy->sql_free_result(Argument::cetera())->shouldBeCalled()->willReturn(null);
1615 $flashMessage = $this->prophesize(FlashMessage::class);
1618 $flashMessageService = $this->prophesize(FlashMessageService::class);
1621 $flashMessageQueue = $this->prophesize(FlashMessageQueue::class);
1622 $flashMessageService->getMessageQueueByIdentifier(Argument::cetera())->willReturn($flashMessageQueue->reveal());
1624 $flashMessageQueue->enqueue($flashMessage)->shouldBeCalled();
1627 $expected[
'databaseRow'][
'aField'] = [];
1629 $this->assertEquals($expected, $this->subject->addData($input));
1635 public function addDataForeignTableHandlesForeignTableRows()
1641 'tableName' =>
'aTable',
1647 'renderType' =>
'selectSingle',
1648 'foreign_table' =>
'fTable',
1649 'foreign_table_prefix' =>
'aPrefix',
1662 $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
1663 $GLOBALS[
'BE_USER'] = $backendUserProphecy->reveal();
1664 $backendUserProphecy->getPagePermsClause(1)->shouldBeCalled()->willReturn(
' 1=1');
1667 $languageServiceProphecy = $this->prophesize(LanguageService::class);
1668 $GLOBALS[
'LANG'] = $languageServiceProphecy->reveal();
1669 $languageServiceProphecy->sL(Argument::cetera())->willReturnArgument(0);
1672 $databaseProphecy = $this->prophesize(DatabaseConnection::class);
1673 $GLOBALS[
'TYPO3_DB'] = $databaseProphecy->reveal();
1674 $databaseProphecy->sql_error()->shouldBeCalled()->willReturn(
false);
1675 $databaseProphecy->sql_free_result(Argument::cetera())->willReturn(null);
1676 $databaseProphecy->exec_SELECT_queryArray(Argument::cetera())->willReturn(
true);
1679 $databaseProphecy->sql_fetch_assoc(Argument::cetera())->shouldBeCalled()->will(
function ($args) use (&$counter) {
1681 if ($counter >= 3) {
1691 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'items'] = [
1693 0 =>
'aPrefix[LLL:EXT:lang/locallang_core.xlf:labels.no_title]',
1695 2 =>
'default-not-found',
1699 0 =>
'aPrefix[LLL:EXT:lang/locallang_core.xlf:labels.no_title]',
1701 2 =>
'default-not-found',
1706 $expected[
'databaseRow'][
'aField'] = [];
1708 $this->assertEquals($expected, $this->subject->addData($input));
1714 public function addDataRemovesItemsByKeepItemsPageTsConfig()
1720 'tableName' =>
'aTable',
1726 'renderType' =>
'selectSingle',
1748 'keepItems' =>
'keep',
1756 $languageService = $this->prophesize(LanguageService::class);
1757 $GLOBALS[
'LANG'] = $languageService->reveal();
1758 $languageService->sL(Argument::cetera())->willReturnArgument(0);
1761 $expected[
'databaseRow'][
'aField'] = [];
1762 unset($expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'items'][1]);
1764 $this->assertEquals($expected, $this->subject->addData($input));
1770 public function addDataRemovesAllItemsByEmptyKeepItemsPageTsConfig()
1776 'tableName' =>
'aTable',
1782 'renderType' =>
'selectSingle',
1812 $languageService = $this->prophesize(LanguageService::class);
1813 $GLOBALS[
'LANG'] = $languageService->reveal();
1814 $languageService->sL(Argument::cetera())->willReturnArgument(0);
1817 $expected[
'databaseRow'][
'aField'] = [];
1818 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'items'] = [];
1820 $this->assertEquals($expected, $this->subject->addData($input));
1826 public function addDataEvaluatesKeepItemsBeforeAddItemsFromPageTsConfig()
1832 'tableName' =>
'aTable',
1838 'renderType' =>
'selectSingle',
1862 '1' =>
'addItem #1',
1863 '12' =>
'addItem #12',
1872 $languageService = $this->prophesize(LanguageService::class);
1873 $GLOBALS[
'LANG'] = $languageService->reveal();
1874 $languageService->sL(Argument::cetera())->willReturnArgument(0);
1877 $expected[
'databaseRow'][
'aField'] = [];
1878 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'items'] = [
1899 $this->assertEquals($expected, $this->subject->addData($input));
1905 public function addDataRemovesItemsByRemoveItemsPageTsConfig()
1911 'tableName' =>
'aTable',
1917 'renderType' =>
'selectSingle',
1939 'removeItems' =>
'remove',
1947 $languageService = $this->prophesize(LanguageService::class);
1948 $GLOBALS[
'LANG'] = $languageService->reveal();
1949 $languageService->sL(Argument::cetera())->willReturnArgument(0);
1952 $expected[
'databaseRow'][
'aField'] = [];
1953 unset($expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'items'][1]);
1955 $this->assertEquals($expected, $this->subject->addData($input));
1961 public function addDataRemovesItemsAddedByAddItemsFromPageTsConfigByRemoveItemsPageTsConfig()
1967 'tableName' =>
'aTable',
1973 'renderType' =>
'selectSingle',
1995 'removeItems' =>
'remove,add',
2006 $languageService = $this->prophesize(LanguageService::class);
2007 $GLOBALS[
'LANG'] = $languageService->reveal();
2008 $languageService->sL(Argument::cetera())->willReturnArgument(0);
2011 $expected[
'databaseRow'][
'aField'] = [];
2012 unset($expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'items'][1]);
2014 $this->assertEquals($expected, $this->subject->addData($input));
2020 public function addDataRemovesItemsByLanguageFieldUserRestriction()
2024 'aField' =>
'aValue,remove'
2026 'tableName' =>
'aTable',
2029 'languageField' =>
'aField',
2035 'renderType' =>
'selectSingle',
2056 $languageService = $this->prophesize(LanguageService::class);
2057 $GLOBALS[
'LANG'] = $languageService->reveal();
2058 $languageService->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue')->willReturn(
'INVALID VALUE "%s"');
2059 $languageService->sL(Argument::cetera())->willReturnArgument(0);
2062 $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
2063 $GLOBALS[
'BE_USER'] = $backendUserProphecy->reveal();
2064 $backendUserProphecy->checkLanguageAccess(
'keep')->shouldBeCalled()->willReturn(
true);
2065 $backendUserProphecy->checkLanguageAccess(
'remove')->shouldBeCalled()->willReturn(
false);
2068 $expected[
'databaseRow'][
'aField'] = [];
2069 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'items'] = [
2070 [
'[ INVALID VALUE "aValue" ]',
'aValue', null, null ],
2071 [
'keepMe',
'keep', null, null ],
2074 $this->assertEquals($expected, $this->subject->addData($input));
2080 public function addDataRemovesItemsByUserAuthModeRestriction()
2084 'aField' =>
'keep,remove'
2086 'tableName' =>
'aTable',
2092 'renderType' =>
'selectSingle',
2093 'authMode' =>
'explicitAllow',
2114 $languageService = $this->prophesize(LanguageService::class);
2115 $GLOBALS[
'LANG'] = $languageService->reveal();
2116 $languageService->sL(Argument::cetera())->willReturnArgument(0);
2119 $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
2120 $GLOBALS[
'BE_USER'] = $backendUserProphecy->reveal();
2121 $backendUserProphecy->checkAuthMode(
'aTable',
'aField',
'keep',
'explicitAllow')->shouldBeCalled()->willReturn(
true);
2122 $backendUserProphecy->checkAuthMode(
'aTable',
'aField',
'remove',
'explicitAllow')->shouldBeCalled()->willReturn(
false);
2125 $expected[
'databaseRow'][
'aField'] = [
'keep'];
2126 unset($expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'items'][1]);
2128 $this->assertEquals($expected, $this->subject->addData($input));
2134 public function addDataKeepsAllPagesDoktypesForAdminUser()
2140 'tableName' =>
'pages',
2146 'renderType' =>
'selectSingle',
2163 $languageService = $this->prophesize(LanguageService::class);
2164 $GLOBALS[
'LANG'] = $languageService->reveal();
2165 $languageService->sL(Argument::cetera())->willReturnArgument(0);
2168 $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
2169 $GLOBALS[
'BE_USER'] = $backendUserProphecy->reveal();
2170 $backendUserProphecy->isAdmin()->shouldBeCalled()->willReturn(
true);
2173 $expected[
'databaseRow'][
'doktype'] = [
'keep'];
2175 $this->assertEquals($expected, $this->subject->addData($input));
2181 public function addDataKeepsAllowedPageTypesForNonAdminUser()
2185 'doktype' =>
'keep',
2187 'tableName' =>
'pages',
2193 'renderType' =>
'selectSingle',
2214 $languageService = $this->prophesize(LanguageService::class);
2215 $GLOBALS[
'LANG'] = $languageService->reveal();
2216 $languageService->sL(Argument::cetera())->willReturnArgument(0);
2219 $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
2220 $GLOBALS[
'BE_USER'] = $backendUserProphecy->reveal();
2221 $backendUserProphecy->isAdmin()->shouldBeCalled()->willReturn(
false);
2222 $backendUserProphecy->groupData = [
2223 'pagetypes_select' =>
'foo,keep,anotherAllowedDoktype',
2227 $expected[
'databaseRow'][
'doktype'] = [
'keep'];
2228 unset($expected[
'processedTca'][
'columns'][
'doktype'][
'config'][
'items'][1]);
2230 $this->assertEquals($expected, $this->subject->addData($input));
2236 public function addDataCallsItemsProcFunc()
2239 'tableName' =>
'aTable',
2241 'aField' =>
'aValue'
2248 'renderType' =>
'selectSingle',
2250 'itemsProcFunc' =>
function (array $parameters, $pObj) {
2251 $parameters[
'items'] = [
2267 $languageService = $this->prophesize(LanguageService::class);
2268 $GLOBALS[
'LANG'] = $languageService->reveal();
2269 $languageService->sL(Argument::cetera())->willReturnArgument(0);
2272 $expected[
'databaseRow'][
'aField'] = [
'aValue'];
2273 $expected[
'processedTca'][
'columns'][
'aField'][
'config'] = [
2275 'renderType' =>
'selectSingle',
2287 $this->assertSame($expected, $this->subject->addData($input));
2293 public function addDataItemsProcFuncReceivesParameters()
2296 'tableName' =>
'aTable',
2298 'aField' =>
'aValue',
2304 'itemsProcFunc.' => [
2305 'itemParamKey' =>
'itemParamValue',
2316 'renderType' =>
'selectSingle',
2324 'itemsProcFunc' =>
function (array $parameters, $pObj) {
2325 if ($parameters[
'items'] !== [ 0 => [
'aLabel',
'aValue'] ]
2326 || $parameters[
'config'][
'aKey'] !==
'aValue'
2327 || $parameters[
'TSconfig'] !== [
'itemParamKey' =>
'itemParamValue' ]
2328 || $parameters[
'table'] !==
'aTable'
2329 || $parameters[
'row'] !== [
'aField' =>
'aValue' ]
2330 || $parameters[
'field'] !==
'aField'
2332 throw new \UnexpectedValueException(
'broken', 1438604329);
2341 $languageService = $this->prophesize(LanguageService::class);
2342 $GLOBALS[
'LANG'] = $languageService->reveal();
2343 $languageService->sL(Argument::cetera())->willReturnArgument(0);
2345 $flashMessage = $this->prophesize(FlashMessage::class);
2348 $flashMessageService = $this->prophesize(FlashMessageService::class);
2351 $flashMessageQueue = $this->prophesize(FlashMessageQueue::class);
2352 $flashMessageService->getMessageQueueByIdentifier(Argument::cetera())->willReturn($flashMessageQueue->reveal());
2355 $flashMessageQueue->enqueue($flashMessage)->shouldNotBeCalled();
2357 $this->subject->addData($input);
2363 public function addDataItemsProcFuncEnqueuesFlashMessageOnException()
2366 'tableName' =>
'aTable',
2368 'aField' =>
'aValue',
2374 'itemsProcFunc.' => [
2375 'itemParamKey' =>
'itemParamValue',
2386 'renderType' =>
'selectSingle',
2394 'itemsProcFunc' =>
function (array $parameters, $pObj) {
2395 throw new \UnexpectedValueException(
'anException', 1438604329);
2403 $languageService = $this->prophesize(LanguageService::class);
2404 $GLOBALS[
'LANG'] = $languageService->reveal();
2406 $flashMessage = $this->prophesize(FlashMessage::class);
2409 $flashMessageService = $this->prophesize(FlashMessageService::class);
2412 $flashMessageQueue = $this->prophesize(FlashMessageQueue::class);
2413 $flashMessageService->getMessageQueueByIdentifier(Argument::cetera())->willReturn($flashMessageQueue->reveal());
2415 $flashMessageQueue->enqueue($flashMessage)->shouldBeCalled();
2417 $this->subject->addData($input);
2423 public function addDataTranslatesItemLabelsFromPageTsConfig()
2427 'aField' =>
'aValue',
2429 'tableName' =>
'aTable',
2435 'renderType' =>
'selectSingle',
2454 'aValue' =>
'labelOverride',
2463 $languageService = $this->prophesize(LanguageService::class);
2464 $GLOBALS[
'LANG'] = $languageService->reveal();
2465 $languageService->sL(
'aLabel')->willReturnArgument(0);
2466 $languageService->sL(
'labelOverride')->shouldBeCalled()->willReturnArgument(0);
2467 $languageService->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue')->willReturn(
'INVALID VALUE "%s"');
2470 $expected[
'databaseRow'][
'aField'] = [
'aValue'];
2471 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'items'][0][0] =
'labelOverride';
2473 $this->assertSame($expected, $this->subject->addData($input));
2474 $this->subject->addData($input);
2480 public function processSelectFieldValueSetsMmForeignRelationValues()
2482 $GLOBALS[
'TCA'][
'foreignTable'] = [];
2485 $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
2486 $GLOBALS[
'BE_USER'] = $backendUserProphecy->reveal();
2489 $database = $this->prophesize(DatabaseConnection::class);
2490 $GLOBALS[
'TYPO3_DB'] = $database->reveal();
2493 'tableName' =>
'aTable',
2504 'renderType' =>
'selectSingle',
2506 'foreign_table' =>
'foreignTable',
2507 'MM' =>
'aTable_foreignTable_mm',
2514 $fieldConfig = $input[
'processedTca'][
'columns'][
'aField'][
'config'];
2516 $relationHandlerProphecy = $this->prophesize(RelationHandler::class);
2519 $relationHandlerUids = [
2524 $relationHandlerProphecy->start(2,
'foreignTable',
'aTable_foreignTable_mm', 42,
'aTable', $fieldConfig)->shouldBeCalled();
2525 $relationHandlerProphecy->getValueArray()->shouldBeCalled()->willReturn($relationHandlerUids);
2528 $expected[
'databaseRow'][
'aField'] = $relationHandlerUids;
2530 $this->assertEquals($expected, $this->subject->addData($input));
2536 public function processSelectFieldValueSetsForeignRelationValues()
2538 $GLOBALS[
'TCA'][
'foreignTable'] = [];
2541 $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
2542 $GLOBALS[
'BE_USER'] = $backendUserProphecy->reveal();
2545 $database = $this->prophesize(DatabaseConnection::class);
2546 $GLOBALS[
'TYPO3_DB'] = $database->reveal();
2549 'tableName' =>
'aTable',
2553 'aField' =>
'22,23,24,25',
2560 'renderType' =>
'selectSingle',
2562 'foreign_table' =>
'foreignTable',
2569 $fieldConfig = $input[
'processedTca'][
'columns'][
'aField'][
'config'];
2571 $relationHandlerProphecy = $this->prophesize(RelationHandler::class);
2574 $relationHandlerUids = [
2579 $relationHandlerProphecy->start(
'22,23,24,25',
'foreignTable',
'', 42,
'aTable', $fieldConfig)->shouldBeCalled();
2580 $relationHandlerProphecy->getValueArray()->shouldBeCalled()->willReturn($relationHandlerUids);
2583 $expected[
'databaseRow'][
'aField'] = $relationHandlerUids;
2585 $this->assertEquals($expected, $this->subject->addData($input));
2591 public function processSelectFieldValueRemovesInvalidDynamicValues()
2593 $languageService = $this->prophesize(LanguageService::class);
2594 $GLOBALS[
'LANG'] = $languageService->reveal();
2595 $languageService->sL(Argument::cetera())->willReturnArgument(0);
2597 $GLOBALS[
'TCA'][
'foreignTable'] = [];
2600 $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
2601 $GLOBALS[
'BE_USER'] = $backendUserProphecy->reveal();
2604 $database = $this->prophesize(DatabaseConnection::class);
2605 $GLOBALS[
'TYPO3_DB'] = $database->reveal();
2607 $relationHandlerProphecy = $this->prophesize(RelationHandler::class);
2609 $relationHandlerProphecy->start(Argument::cetera())->shouldBeCalled();
2610 $relationHandlerProphecy->getValueArray(Argument::cetera())->shouldBeCalled()->willReturn([1]);
2613 'tableName' =>
'aTable',
2615 'aField' =>
'1,2,bar,foo',
2622 'renderType' =>
'selectSingleBox',
2623 'foreign_table' =>
'foreignTable',
2626 [
'foo',
'foo', null, null],
2635 $expected[
'databaseRow'][
'aField'] = [
'foo', 1];
2637 $this->assertEquals($expected, $this->subject->addData($input));
2645 $languageService = $this->prophesize(LanguageService::class);
2646 $GLOBALS[
'LANG'] = $languageService->reveal();
2647 $languageService->sL(Argument::cetera())->willReturnArgument(0);
2650 'tableName' =>
'aTable',
2652 'aField' =>
'foo,bar',
2659 'renderType' =>
'selectSingle',
2662 [
'foo',
'foo', null, null],
2663 [
'bar',
'bar', null, null],
2672 $expected[
'databaseRow'][
'aField'] = [
2677 $this->assertEquals($expected, $this->subject->addData($input));
2685 $languageService = $this->prophesize(LanguageService::class);
2686 $GLOBALS[
'LANG'] = $languageService->reveal();
2687 $languageService->sL(Argument::cetera())->willReturnArgument(0);
2690 'tableName' =>
'aTable',
2699 'renderType' =>
'selectSingle',
2709 $expected[
'databaseRow'][
'aField'] = [];
2711 $this->assertEquals($expected, $this->subject->addData($input));
2719 $languageService = $this->prophesize(LanguageService::class);
2720 $GLOBALS[
'LANG'] = $languageService->reveal();
2721 $languageService->sL(Argument::cetera())->willReturnArgument(0);
2724 'tableName' =>
'aTable',
2733 'renderType' =>
'selectSingle',
2736 [
'a',
'', null, null],
2737 [
'b',
'b', null, null],
2738 [
'c',
'c', null, null],
2747 $expected[
'databaseRow'][
'aField'] = [
2752 $this->assertEquals($expected, $this->subject->addData($input));
2760 $languageService = $this->prophesize(LanguageService::class);
2761 $GLOBALS[
'LANG'] = $languageService->reveal();
2762 $languageService->sL(Argument::cetera())->willReturnArgument(0);
2764 $relationHandlerProphecy = $this->prophesize(RelationHandler::class);
2766 $relationHandlerProphecy->start(Argument::cetera())->shouldNotBeCalled();
2767 $relationHandlerProphecy->getValueArray(Argument::cetera())->shouldNotBeCalled();
2770 'tableName' =>
'aTable',
2779 'renderType' =>
'selectSingle',
2782 [
'foo',
'foo', null, null],
2791 $expected[
'databaseRow'][
'aField'] = [
'foo'];
2793 $this->assertEquals($expected, $this->subject->addData($input));
2801 $languageService = $this->prophesize(LanguageService::class);
2802 $GLOBALS[
'LANG'] = $languageService->reveal();
2803 $languageService->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue')->willReturn(
'INVALID VALUE "%s"');
2804 $languageService->sL(Argument::cetera())->willReturnArgument(0);
2806 $relationHandlerProphecy = $this->prophesize(RelationHandler::class);
2808 $relationHandlerProphecy->start(Argument::cetera())->shouldNotBeCalled();
2809 $relationHandlerProphecy->getValueArray(Argument::cetera())->shouldNotBeCalled();
2812 'tableName' =>
'aTable',
2814 'aField' =>
'1,2,bar,foo',
2821 'renderType' =>
'selectSingle',
2824 [
'foo',
'foo', null, null],
2833 $expected[
'databaseRow'][
'aField'] = [
'foo'];
2834 $expected[
'processedTca'][
'columns'][
'aField'][
'config'][
'items'] = [
2835 [
'[ INVALID VALUE "bar" ]',
'bar', null, null],
2836 [
'[ INVALID VALUE "2" ]',
'2', null, null],
2837 [
'[ INVALID VALUE "1" ]',
'1', null, null],
2838 [
'foo',
'foo', null, null],
2840 $this->assertEquals($expected, $this->subject->addData($input));
2852 'Relation with MM table and new status with default values' => [
2854 'tableName' =>
'aTable',
2858 'aField' =>
'24,35',
2865 'renderType' =>
'selectSingle',
2867 'MM' =>
'mm_aTable_foreignTable',
2868 'foreign_table' =>
'foreignTable',
2882 'Relation with MM table and item array in list but no new status' => [
2884 'tableName' =>
'aTable',
2887 'aField' =>
'24,35',
2894 'renderType' =>
'selectSingle',
2896 'MM' =>
'mm_aTable_foreignTable',
2897 'foreign_table' =>
'foreignTable',
2907 'Relation with MM table and maxitems = 1 processes field value (item count)' => [
2909 'tableName' =>
'aTable',
2920 'renderType' =>
'selectSingle',
2922 'MM' =>
'mm_aTable_foreignTable',
2923 'foreign_table' =>
'foreignTable',
2935 'Relation with MM table and maxitems = 1 results in empty array if no items are set' => [
2937 'tableName' =>
'aTable',
2948 'renderType' =>
'selectSingle',
2950 'MM' =>
'mm_aTable_foreignTable',
2951 'foreign_table' =>
'foreignTable',
2972 public function processSelectFieldSetsCorrectValuesForMmRelations(array $input, array $overrideRelationHandlerSettings, array $relationHandlerUids)
2974 $field = $input[
'databaseRow'][
'aField'];
2975 $foreignTable = isset($overrideRelationHandlerSettings[
'foreign_table']) ? $overrideRelationHandlerSettings[
'foreign_table'] : $input[
'processedTca'][
'columns'][
'aField'][
'config'][
'foreign_table'];
2976 $mmTable = isset($overrideRelationHandlerSettings[
'MM']) ? $overrideRelationHandlerSettings[
'MM'] : $input[
'processedTca'][
'columns'][
'aField'][
'config'][
'MM'];
2977 $uid = $input[
'databaseRow'][
'uid'];
2978 $tableName = $input[
'tableName'];
2979 $fieldConfig = $input[
'processedTca'][
'columns'][
'aField'][
'config'];
2981 $GLOBALS[
'TCA'][$foreignTable] = [];
2984 $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
2985 $GLOBALS[
'BE_USER'] = $backendUserProphecy->reveal();
2988 $database = $this->prophesize(DatabaseConnection::class);
2989 $GLOBALS[
'TYPO3_DB'] = $database->reveal();
2992 $relationHandlerProphecy = $this->prophesize(RelationHandler::class);
2995 $relationHandlerProphecy->start($field, $foreignTable, $mmTable, $uid, $tableName, $fieldConfig)->shouldBeCalled();
2996 $relationHandlerProphecy->getValueArray()->shouldBeCalled()->willReturn($relationHandlerUids);
2999 $expected[
'databaseRow'][
'aField'] = $relationHandlerUids;
3001 $this->assertEquals($expected, $this->subject->addData($input));