17 use Prophecy\Argument;
18 use Prophecy\Prophecy\ObjectProphecy;
36 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
60 'seconds' => 60 * 60 * 24 * 365,
61 'expectedLabel' =>
'1 year'
64 'seconds' => 60 * 60 * 24 * 365 * 2,
65 'expectedLabel' =>
'2 yrs'
67 'Single negative year' => [
68 'seconds' => 60 * 60 * 24 * 365 * -1,
69 'expectedLabel' =>
'-1 year'
71 'Plural negative years' => [
72 'seconds' => 60 * 60 * 24 * 365 * 2 * -1,
73 'expectedLabel' =>
'-2 yrs'
76 'seconds' => 60 * 60 * 24,
77 'expectedLabel' =>
'1 day'
80 'seconds' => 60 * 60 * 24 * 2,
81 'expectedLabel' =>
'2 days'
83 'Single negative day' => [
84 'seconds' => 60 * 60 * 24 * -1,
85 'expectedLabel' =>
'-1 day'
87 'Plural negative days' => [
88 'seconds' => 60 * 60 * 24 * 2 * -1,
89 'expectedLabel' =>
'-2 days'
93 'expectedLabel' =>
'1 hour'
96 'seconds' => 60 * 60 * 2,
97 'expectedLabel' =>
'2 hrs'
99 'Single negative hour' => [
100 'seconds' => 60 * 60 * -1,
101 'expectedLabel' =>
'-1 hour'
103 'Plural negative hours' => [
104 'seconds' => 60 * 60 * 2 * -1,
105 'expectedLabel' =>
'-2 hrs'
109 'expectedLabel' =>
'1 min'
111 'Plural minutes' => [
113 'expectedLabel' =>
'2 min'
115 'Single negative minute' => [
116 'seconds' => 60 * -1,
117 'expectedLabel' =>
'-1 min'
119 'Plural negative minutes' => [
120 'seconds' => 60 * 2 * -1,
121 'expectedLabel' =>
'-2 min'
125 'expectedLabel' =>
'0 min'
197 'allowed' =>
'pages',
198 'internal_type' =>
'db',
222 'internal_type' =>
'db',
223 'allowed' =>
'index_config,pages',
243 $connectionProphet = $this->prophesize(Connection::class);
244 $connectionProphet->quote(Argument::cetera())->will(
function ($arguments) {
245 return "'" . $arguments[0] .
"'";
247 $connectionProphet->quoteIdentifier(Argument::cetera())->will(
function ($arguments) {
248 return '`' . $arguments[0] .
'`';
251 $restrictionProphet = $this->prophesize(DefaultRestrictionContainer::class);
252 $restrictionProphet->removeAll()->willReturn($restrictionProphet->reveal());
253 $restrictionProphet->add(Argument::cetera())->willReturn($restrictionProphet->reveal());
255 $queryBuilderProphet = $this->prophesize(QueryBuilder::class);
256 $queryBuilderProphet->expr()->willReturn(
257 GeneralUtility::makeInstance(ExpressionBuilder::class, $connectionProphet->reveal())
259 $queryBuilderProphet->getRestrictions()->willReturn($restrictionProphet->reveal());
260 $queryBuilderProphet->quoteIdentifier(Argument::cetera())->will(
function ($arguments) {
261 return '`' . $arguments[0] .
'`';
264 $connectionPoolProphet = $this->prophesize(ConnectionPool::class);
265 $connectionPoolProphet->getConnectionForTable($tableName)
266 ->willReturn($connectionProphet->reveal());
267 $connectionPoolProphet->getQueryBuilderForTable($tableName)
269 ->willReturn($queryBuilderProphet->reveal());
271 return [$queryBuilderProphet, $connectionPoolProphet, $connectionProphet, $restrictionProphet];
280 $relationHandlerProphet = $this->prophesize(RelationHandler::class);
281 $relationHandlerProphet->start(Argument::cetera())->shouldBeCalled();
283 $relationHandlerInstance = $relationHandlerProphet->reveal();
284 $relationHandlerInstance->tableArray[
'sys_category'] = [1, 2];
287 $statementProphet = $this->prophesize(\Doctrine\DBAL\Driver\Statement::class);
288 $statementProphet->fetch()->shouldBeCalled()->willReturn(
291 'title' =>
'Category 1',
295 'title' =>
'Category 2',
301 $queryBuilderProphet->select(
'uid',
'sys_category.title')->willReturn($queryBuilderProphet->reveal());
302 $queryBuilderProphet->from(
'sys_category')->willReturn($queryBuilderProphet->reveal());
303 $queryBuilderProphet->where(
'`uid` IN (:dcValue1)')->willReturn($queryBuilderProphet->reveal());
304 $queryBuilderProphet->createNamedParameter([1, 2], Connection::PARAM_INT_ARRAY)->willReturn(
':dcValue1');
305 $queryBuilderProphet->execute()->willReturn($statementProphet->reveal());
307 GeneralUtility::addInstance(RelationHandler::class, $relationHandlerInstance);
308 GeneralUtility::addInstance(ConnectionPool::class, $connectionPoolProphet->reveal());
316 'foreign_table' =>
'sys_category',
317 'MM' =>
'sys_category_record_mm',
318 'MM_match_fields' => [
319 'fieldname' =>
'categories',
320 'tablesnames' =>
'pages',
322 'MM_opposite_field' =>
'items',
328 'ctrl' => [
'label' =>
'title'],
333 'internal_type' =>
'db',
335 'MM' =>
'sys_category_record_mm',
336 'MM_oppositeUsage' => [],
345 'Category 1; Category 2',
364 $languageServiceProphecy = $this->prophesize(LanguageService::class);
365 $languageServiceProphecy->sL(Argument::cetera())->willReturn(
' min| hrs| days| yrs| min| hour| day| year');
366 $GLOBALS[
'LANG'] = $languageServiceProphecy->reveal();
368 $GLOBALS[
'EXEC_TIME'] = mktime(0, 0, 0, 8, 30, 2015);
391 'typeSafe Setting' => [
395 'non typesafe setting' => [
399 'setting disabled typesafe' => [
401 '28-08-15 (-2 days)',
403 'setting disabled not typesafe' => [
405 '28-08-15 (-2 days)',
421 $languageServiceProphecy = $this->prophesize(LanguageService::class);
422 $languageServiceProphecy->sL(Argument::cetera())->willReturn(
' min| hrs| days| yrs| min| hour| day| year');
423 $GLOBALS[
'LANG'] = $languageServiceProphecy->reveal();
425 $GLOBALS[
'EXEC_TIME'] = mktime(0, 0, 0, 8, 30, 2015);
434 'disableAgeDisplay' => $input,
465 $languageServiceProphecy = $this->prophesize(\
TYPO3\CMS\Core\Localization\LanguageService::class);
466 $languageServiceProphecy->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:yes')->willReturn(
'Yes');
467 $languageServiceProphecy->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:no')->willReturn(
'No');
468 $GLOBALS[
'LANG'] = $languageServiceProphecy->reveal();
487 'invertStateDisplay' =>
true,
495 $languageServiceProphecy = $this->prophesize(\
TYPO3\CMS\Core\Localization\LanguageService::class);
496 $languageServiceProphecy->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:yes')->willReturn(
'Yes');
497 $languageServiceProphecy->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:no')->willReturn(
'No');
498 $GLOBALS[
'LANG'] = $languageServiceProphecy->reveal();
515 'table' =>
'test_table',
517 'presetFields' => [],
519 'expectedFields' =>
'uid'
522 'table' =>
'test_table',
524 'presetFields' => [],
530 'expectedFields' =>
'uid,label'
533 'table' =>
'test_table',
535 'presetFields' => [],
538 'label_alt' =>
'label,label2'
541 'expectedFields' =>
'uid,label,label2'
543 'versioningWS set' => [
544 'table' =>
'test_table',
546 'presetFields' => [],
549 'versioningWS' => true
552 'expectedFields' =>
'uid,t3ver_id,t3ver_state,t3ver_wsid,t3ver_count'
554 'selicon_field set' => [
555 'table' =>
'test_table',
557 'presetFields' => [],
560 'selicon_field' =>
'field'
563 'expectedFields' =>
'uid,field'
565 'typeicon_column set' => [
566 'table' =>
'test_table',
568 'presetFields' => [],
571 'typeicon_column' =>
'field'
574 'expectedFields' =>
'uid,field'
576 'enablecolumns set' => [
577 'table' =>
'test_table',
579 'presetFields' => [],
583 'disabled' =>
'hidden',
584 'starttime' =>
'start',
586 'fe_group' =>
'groups'
590 'expectedFields' =>
'uid,hidden,start,stop,groups'
592 'label set to uid' => [
593 'table' =>
'test_table',
595 'presetFields' => [],
601 'expectedFields' =>
'uid'
620 $this->assertEquals($selectFields, $expectedFields);
636 'table' =>
'tt_content',
637 'col' =>
'menu_type',
652 'expectedLabel' =>
'Item 2'
654 'item set twice' => [
655 'table' =>
'tt_content',
656 'col' =>
'menu_type',
672 'expectedLabel' =>
'Item 2a'
674 'item not found' => [
675 'table' =>
'tt_content',
676 'col' =>
'menu_type',
691 'expectedLabel' => null
710 $this->assertEquals($label, $expectedLabel);
725 'no field found' => [
727 'table' =>
'tt_content',
728 'col' =>
'menu_type',
743 'expectedLabel' =>
''
745 'no tsconfig set' => [
747 'table' =>
'tt_content',
748 'col' =>
'menu_type',
763 'expectedLabel' =>
'Item 2'
808 'return value if found' => [
817 '0' => [
'aFooLabel',
'foo'],
818 '1' => [
'aBarLabel',
'bar']
825 'aFooLabel, aBarLabel'
827 'page TSconfig overrules TCA' => [
836 '0' => [
'aFooLabel',
'foo'],
837 '1' => [
'aBarLabel',
'bar']
844 'addItems.' => [
'add' =>
'aNewLabel'],
845 'altLabels.' => [
'bar' =>
'aBarDiffLabel'],
847 'aFooLabel, aBarDiffLabel, aNewLabel'
866 $GLOBALS[
'LANG'] = $this->createMock(LanguageService::class);
867 $GLOBALS[
'LANG']->expects($this->any())->method(
'sL')->will($this->returnArgument(0));
871 $this->assertEquals($expectedLabel, $label);
887 '0' => [
'aFooLabel',
'foo'],
888 '1' => [
'aBarLabel',
'bar']
895 $GLOBALS[
'LANG'] = $this->createMock(LanguageService::class);
896 $GLOBALS[
'LANG']->expects($this->any())->method(
'sL')->will($this->returnArgument(0));
900 $this->assertEquals(
'aFooLabel, aBarLabel', $label);
916 '0' => [
'aFooLabel',
'foo']
923 $GLOBALS[
'LANG'] = $this->createMock(LanguageService::class);
924 $GLOBALS[
'LANG']->expects($this->any())->method(
'sL')->will($this->returnArgument(0));
928 $this->assertEquals(
'invalidKey', $label);
942 unset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_befunc.php'][
'viewOnClickClass']);
944 $alternativeUrl =
'https://typo3.org/about/typo3-the-cms/the-history-of-typo3/#section';
945 $onclickCode =
'var previewWin = window.open(' . GeneralUtility::quoteJSvalue($alternativeUrl) .
',\'newTYPO3frontendWindow\');' . LF
946 .
'if (previewWin.location.href === ' . GeneralUtility::quoteJSvalue($alternativeUrl) .
') { previewWin.location.reload(); };';
947 $this->assertStringMatchesFormat(
959 $languageServiceProphecy = $this->prophesize(LanguageService::class);
960 $languageServiceProphecy->sL(Argument::cetera())->willReturn(
' min| hrs| days| yrs| min| hour| day| year');
961 $GLOBALS[
'LANG'] = $languageServiceProphecy->reveal();
962 $GLOBALS[
'EXEC_TIME'] = mktime(0, 0, 0, 3, 23, 2016);
979 self::assertSame([
'uid',
'pid'], $computedPropertyNames);
997 self::assertSame($expected, $computedProperties);
1009 [
'tt_content',
'13']
1011 'multiple underscores' => [
1012 'tx_runaway_domain_model_crime_scene_1234',
1013 [
'tx_runaway_domain_model_crime_scene',
'1234']
1025 self::assertSame($expected, $result);
1036 $expected = [
'called.' => [
'config']];
1038 $parserProphecy = $this->prophesize(TsConfigParser::class);
1039 $parserProphecy->parseTSconfig(Argument::cetera())->willReturn([
'hash' => $pageId,
'TSconfig' => $expected]);
1040 GeneralUtility::addInstance(TsConfigParser::class, $parserProphecy->reveal());
1042 $cacheManagerProphecy = $this->prophesize(CacheManager::class);
1043 $cacheProphecy = $this->prophesize(FrontendInterface::class);
1044 $cacheManagerProphecy->getCache(
'cache_runtime')->willReturn($cacheProphecy->reveal());
1045 $cacheHashProphecy = $this->prophesize(FrontendInterface::class);
1046 $cacheManagerProphecy->hasCache(
'extbase_reflection')->willReturn(
false);
1047 $cacheManagerProphecy->getCache(
'cache_hash')->willReturn($cacheHashProphecy->reveal());
1048 $cacheProphecy->has(Argument::cetera())->willReturn(
false);
1049 $cacheProphecy->get(Argument::cetera())->willReturn(
false);
1050 $cacheProphecy->set(Argument::cetera())->willReturn(
false);
1051 $cacheProphecy->get(
'backendUtilityBeGetRootLine')->willReturn([
'13--1' => []]);
1052 GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
1053 $signalSlotDispatcherProphecy = $this->prophesize(SignalSlotDispatcher::class);
1054 $signalSlotDispatcherProphecy->dispatch(Argument::any(), Argument::any(), Argument::type(
'array'))->willReturnArgument(2);
1055 GeneralUtility::setSingletonInstance(SignalSlotDispatcher::class, $signalSlotDispatcherProphecy->reveal());
1058 $this->assertEquals($expected, $result);
1066 $tableName =
'table_a';
1067 $fieldName =
'field_a';
1068 $GLOBALS[
'TCA'][$tableName][
'columns'][$fieldName][
'config'] = [];
1078 $tableName =
'table_a';
1079 $GLOBALS[
'TCA'][$tableName][
'ctrl'][
'versioningWS'] =
'not_empty';
1087 $this->assertSame($reference, $rr);
1096 $tableName =
'table_a';
1097 $fieldName =
'field_a';
1098 $GLOBALS[
'TCA'][$tableName][
'columns'][$fieldName][
'config'] = $config;
1105 'invalid table' => [
1108 'foreign_table' =>
'table_b',
1114 'foreign_table' =>
'',
1120 'foreign_table' =>
'sys_file_reference',
1126 'foreign_table' =>
'sys_file_reference',
1132 'foreign_table' =>
'',
1144 $tableName =
'table_a';
1151 $this->assertSame($reference, $row);
1160 $tableName =
'table_a';
1161 $GLOBALS[
'TCA'][$tableName][
'ctrl'][
'versioningWS'] =
'not_empty';
1170 $tableName =
'table_a';
1171 $fieldName =
'field_a';
1172 $relationHandler = $this->prophesize(RelationHandler::class);
1173 $relationHandler->start(
1175 'sys_file_reference',
1179 [
'type' =>
'inline',
'foreign_table' =>
'sys_file_reference']
1180 )->shouldBeCalled();
1181 $relationHandler->tableArray = [
'sys_file_reference' => []];
1182 $relationHandler->processDeletePlaceholder()->shouldBeCalled();
1183 GeneralUtility::addInstance(RelationHandler::class, $relationHandler->reveal());
1184 $GLOBALS[
'TCA'][$tableName][
'columns'][$fieldName][
'config'] = [
1186 'foreign_table' =>
'sys_file_reference',
1189 $fieldName =>
'foo',
1202 $tableName =
'table_a';
1203 $GLOBALS[
'TCA'][$tableName][
'ctrl'][
'versioningWS'] =
'not_empty';
1213 $tableName =
'table_a';
1224 $tableName =
'table_a';