2 declare(strict_types = 1);
18 use PHPUnit\Framework\Exception;
19 use Prophecy\Argument;
20 use Psr\Http\Message\ServerRequestInterface;
31 use TYPO3\CMS\Core\Package\PackageManager;
70 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
71 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
106 'TEXT' => TextContentObject::class,
107 'CASE' => CaseContentObject::class,
108 'COBJ_ARRAY' => ContentObjectArrayContentObject::class,
109 'COA' => ContentObjectArrayContentObject::class,
110 'COA_INT' => ContentObjectArrayInternalContentObject::class,
111 'USER' => UserContentObject::class,
112 'USER_INT' => UserInternalContentObject::class,
113 'FILE' => FileContentObject::class,
114 'FILES' => FilesContentObject::class,
115 'IMAGE' => ImageContentObject::class,
116 'IMG_RESOURCE' => ImageResourceContentObject::class,
117 'CONTENT' => ContentContentObject::class,
118 'RECORDS' => RecordsContentObject::class,
119 'HMENU' => HierarchicalMenuContentObject::class,
120 'CASEFUNC' => CaseContentObject::class,
121 'LOAD_REGISTER' => LoadRegisterContentObject::class,
122 'RESTORE_REGISTER' => RestoreRegisterContentObject::class,
123 'TEMPLATE' => TemplateContentObject::class,
124 'FLUIDTEMPLATE' => FluidTemplateContentObject::class,
125 'SVG' => ScalableVectorGraphicsContentObject::class,
126 'EDITPANEL' => EditPanelContentObject::class
132 protected function setUp(): void
134 $GLOBALS[
'SIM_ACCESS_TIME'] = 1534278180;
135 $packageManagerMock = $this->getMockBuilder(PackageManager::class)
136 ->disableOriginalConstructor()
138 $this->templateServiceMock =
139 $this->getMockBuilder(TemplateService::class)
140 ->setConstructorArgs([
null, $packageManagerMock])
141 ->setMethods([
'linkData'])
143 $pageRepositoryMock =
144 $this->getAccessibleMock(PageRepository::class, [
'getRawRecord',
'getMountPointInfo']);
145 $this->frontendControllerMock =
146 $this->getAccessibleMock(
147 TypoScriptFrontendController::class,
153 $this->frontendControllerMock->_set(
'context', GeneralUtility::makeInstance(Context::class));
155 $this->frontendControllerMock->config = [];
156 $this->frontendControllerMock->page = [];
157 $this->frontendControllerMock->sys_page = $pageRepositoryMock;
160 $this->subject = $this->getAccessibleMock(
161 ContentObjectRenderer::class,
162 [
'getResourceFactory',
'getEnvironmentVariable'],
163 [$this->frontendControllerMock]
166 $logger = $this->prophesize(Logger::class);
167 $this->subject->setLogger($logger->reveal());
168 $this->subject->setContentObjectClassMap($this->contentObjectMap);
169 $this->subject->start([],
'tt_content');
193 $expected = mb_convert_encoding($expected,
'utf-8',
'iso-8859-1');
204 $cacheManagerProphecy = $this->prophesize(CacheManager::class);
205 $cacheProphecy = $this->prophesize(CacheFrontendInterface::class);
206 $cacheManagerProphecy->getCache(
'cache_imagesizes')->willReturn($cacheProphecy->reveal());
207 $cacheProphecy->get(Argument::cetera())->willReturn(
false);
208 $cacheProphecy->set(Argument::cetera(),
null)->willReturn(
false);
209 GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
211 $resourceFactory = $this->createMock(ResourceFactory::class);
212 $this->subject->expects($this->any())->method(
'getResourceFactory')->will($this->returnValue($resourceFactory));
214 $className = $this->getUniqueId(
'tx_coretest');
215 $getImgResourceHookMock = $this->getMockBuilder(ContentObjectGetImageResourceHookInterface::class)
216 ->setMethods([
'getImgResourcePostProcess'])
217 ->setMockClassName($className)
219 $getImgResourceHookMock
220 ->expects($this->once())
221 ->method(
'getImgResourcePostProcess')
222 ->will($this->returnCallback([$this,
'isGetImgResourceHookCalledCallback']));
223 $getImgResourceHookObjects = [$getImgResourceHookMock];
224 $this->subject->_setRef(
'getImgResourceHookObjects', $getImgResourceHookObjects);
225 $this->subject->getImgResource(
'typo3/sysext/core/Tests/Unit/Utility/Fixtures/clear.gif', []);
242 ContentObjectRenderer $parent
244 $this->assertEquals(
'typo3/sysext/core/Tests/Unit/Utility/Fixtures/clear.gif', $file);
245 $this->assertEquals(
'typo3/sysext/core/Tests/Unit/Utility/Fixtures/clear.gif', $imageResource[
'origFile']);
246 $this->assertTrue(is_array($fileArray));
247 $this->assertTrue($parent instanceof ContentObjectRenderer);
248 return $imageResource;
270 $className = TextContentObject::class;
271 $contentObjectName =
'TEST_TEXT';
272 $this->subject->registerContentObjectClass(
276 $object = $this->subject->getContentObject($contentObjectName);
277 $this->assertInstanceOf($className, $object);
289 $className = TextContentObject::class;
290 $contentObjectName =
'TEST_TEXT';
291 $classMap = [$contentObjectName => $className];
292 $this->subject->setContentObjectClassMap($classMap);
293 $object = $this->subject->getContentObject($contentObjectName);
294 $this->assertInstanceOf($className, $object);
307 $className = TextContentObject::class;
308 $contentObjectName =
'TEST_TEXT';
310 $this->subject->setContentObjectClassMap($classMap);
311 $classMap[$contentObjectName] = $className;
312 $object = $this->subject->getContentObject($contentObjectName);
313 $this->assertNull($object);
322 $object = $this->subject->getContentObject(
'FOO');
323 $this->assertNull($object);
332 $this->expectException(ContentRenderingException::class);
333 $this->subject->registerContentObjectClass(
337 $this->subject->getContentObject(
'STDCLASS');
346 foreach ($this->contentObjectMap as $name => $className) {
347 $dataProvider[] = [$name, $className];
349 return $dataProvider;
366 is_subclass_of($className, AbstractContentObject::class)
368 $object = $this->subject->getContentObject($objectName);
369 $this->assertInstanceOf($className, $object);
380 $this->subject->expects($this->any())->method(
'getEnvironmentVariable')->with($this->equalTo(
'QUERY_STRING'))->will(
381 $this->returnValue(
'key1=value1&key2=value2&key3[key31]=value31&key3[key32][key321]=value321&key3[key32][key322]=value322')
383 $getQueryArgumentsConfiguration = [];
384 $getQueryArgumentsConfiguration[
'exclude'] = [];
385 $getQueryArgumentsConfiguration[
'exclude'][] =
'key1';
386 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key31]';
387 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key32][key321]';
388 $getQueryArgumentsConfiguration[
'exclude'] = implode(
',', $getQueryArgumentsConfiguration[
'exclude']);
390 $actualResult = $this->subject->getQueryArguments($getQueryArgumentsConfiguration);
391 $this->assertEquals($expectedResult, $actualResult);
403 'key31' =>
'value31',
405 'key321' =>
'value321',
406 'key322' =>
'value322'
410 $getQueryArgumentsConfiguration = [];
411 $getQueryArgumentsConfiguration[
'method'] =
'GET';
412 $getQueryArgumentsConfiguration[
'exclude'] = [];
413 $getQueryArgumentsConfiguration[
'exclude'][] =
'key1';
414 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key31]';
415 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key32][key321]';
416 $getQueryArgumentsConfiguration[
'exclude'] = implode(
',', $getQueryArgumentsConfiguration[
'exclude']);
418 $actualResult = $this->subject->getQueryArguments($getQueryArgumentsConfiguration);
419 $this->assertEquals($expectedResult, $actualResult);
427 $this->subject->expects($this->any())->method(
'getEnvironmentVariable')->with($this->equalTo(
'QUERY_STRING'))->will(
428 $this->returnValue(
'key1=value1')
430 $getQueryArgumentsConfiguration = [];
431 $overruleArguments = [
433 'key1' =>
'value1Overruled',
435 'key2' =>
'value2Overruled'
437 $expectedResult =
'&key1=value1Overruled';
438 $actualResult = $this->subject->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments);
439 $this->assertEquals($expectedResult, $actualResult);
451 'key31' =>
'value31',
453 'key321' =>
'value321',
454 'key322' =>
'value322'
458 $getQueryArgumentsConfiguration = [];
459 $getQueryArgumentsConfiguration[
'method'] =
'POST';
460 $getQueryArgumentsConfiguration[
'exclude'] = [];
461 $getQueryArgumentsConfiguration[
'exclude'][] =
'key1';
462 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key31]';
463 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key32][key321]';
464 $getQueryArgumentsConfiguration[
'exclude'] = implode(
',', $getQueryArgumentsConfiguration[
'exclude']);
465 $overruleArguments = [
467 'key2' =>
'value2Overruled',
471 'key321' =>
'value321Overruled',
473 'key322' =>
'value322Overruled',
475 'key323' =>
'value323Overruled'
480 $actualResult = $this->subject->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments);
481 $this->assertEquals($expectedResult, $actualResult);
489 $this->subject->expects($this->any())->method(
'getEnvironmentVariable')->with($this->equalTo(
'QUERY_STRING'))->will(
490 $this->returnValue(
'key1=value1&key2=value2&key3[key31]=value31&key3[key32][key321]=value321&key3[key32][key322]=value322')
496 'key31' =>
'value31',
498 'key321' =>
'value321',
499 'key322' =>
'value322'
503 $getQueryArgumentsConfiguration = [];
504 $getQueryArgumentsConfiguration[
'exclude'] = [];
505 $getQueryArgumentsConfiguration[
'exclude'][] =
'key1';
506 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key31]';
507 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key32][key321]';
508 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key32][key322]';
509 $getQueryArgumentsConfiguration[
'exclude'] = implode(
',', $getQueryArgumentsConfiguration[
'exclude']);
510 $overruleArguments = [
512 'key2' =>
'value2Overruled',
516 'key321' =>
'value321Overruled',
518 'key323' =>
'value323Overruled'
522 $expectedResult = $this->
rawUrlEncodeSquareBracketsInUrl(
'&key2=value2Overruled&key3[key32][key321]=value321Overruled&key3[key32][key323]=value323Overruled');
523 $actualResult = $this->subject->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments,
true);
524 $this->assertEquals($expectedResult, $actualResult);
525 $getQueryArgumentsConfiguration[
'method'] =
'POST';
526 $actualResult = $this->subject->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments,
true);
527 $this->assertEquals($expectedResult, $actualResult);
542 'key331' =>
'POST331',
543 'key332' =>
'POST332',
552 'key331' =>
'GET331',
556 $getQueryArgumentsConfiguration = [];
557 $getQueryArgumentsConfiguration[
'method'] =
'POST,GET';
558 $expectedResult = $this->
rawUrlEncodeSquareBracketsInUrl(
'&key1=POST1&key2=GET2&key3[key31]=POST31&key3[key32]=GET32&key3[key33][key331]=GET331&key3[key33][key332]=POST332');
559 $actualResult = $this->subject->getQueryArguments($getQueryArgumentsConfiguration);
560 $this->assertEquals($expectedResult, $actualResult);
575 'key331' =>
'GET331',
576 'key332' =>
'GET332',
585 'key331' =>
'POST331',
589 $getQueryArgumentsConfiguration = [];
590 $getQueryArgumentsConfiguration[
'method'] =
'GET,POST';
591 $expectedResult = $this->
rawUrlEncodeSquareBracketsInUrl(
'&key1=GET1&key2=POST2&key3[key31]=GET31&key3[key32]=POST32&key3[key33][key331]=POST331&key3[key33][key332]=GET332');
592 $actualResult = $this->subject->getQueryArguments($getQueryArgumentsConfiguration);
593 $this->assertEquals($expectedResult, $actualResult);
604 return str_replace([
'[',
']'], [
'%5B',
'%5D'], $string);
615 $this->assertEquals(
'бла', $this->subject->crop(
'бла',
'3|...'));
633 $plainText =
'Kasper Sk' . chr(229) .
'rh' . chr(248)
634 .
'j implemented the original version of the crop function.';
635 $textWithMarkup =
'<strong><a href="mailto:kasper@typo3.org">Kasper Sk'
636 . chr(229) .
'rh' . chr(248) .
'j</a> implemented</strong> the '
637 .
'original version of the crop function.';
638 $textWithEntities =
'Kasper Skårhøj implemented the; '
639 .
'original ' .
'version of the crop function.';
640 $textWithLinebreaks =
"Lorem ipsum dolor sit amet,\n"
641 .
"consetetur sadipscing elitr,\n"
642 .
'sed diam nonumy eirmod tempor invidunt ut labore e'
643 .
't dolore magna aliquyam';
646 'plain text; 11|...' => [
647 'Kasper Sk' . chr(229) .
'r...',
651 'plain text; -58|...' => [
652 '...h' . chr(248) .
'j implemented the original version of '
653 .
'the crop function.',
657 'plain text; 4|...|1' => [
662 'plain text; 20|...|1' => [
663 'Kasper Sk' . chr(229) .
'rh' . chr(248) .
'j...',
667 'plain text; -5|...|1' => [
672 'plain text; -49|...|1' => [
673 '...the original version of the crop function.',
677 'text with markup; 11|...' => [
678 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk'
679 . chr(229) .
'r...</a></strong>',
683 'text with markup; 13|...' => [
684 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk'
685 . chr(229) .
'rh' . chr(248) .
'...</a></strong>',
689 'text with markup; 14|...' => [
690 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk'
691 . chr(229) .
'rh' . chr(248) .
'j</a>...</strong>',
695 'text with markup; 15|...' => [
696 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk'
697 . chr(229) .
'rh' . chr(248) .
'j</a> ...</strong>',
701 'text with markup; 29|...' => [
702 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk'
703 . chr(229) .
'rh' . chr(248) .
'j</a> implemented</strong> '
708 'text with markup; -58|...' => [
709 '<strong><a href="mailto:kasper@typo3.org">...h' . chr(248)
710 .
'j</a> implemented</strong> the original version of the crop '
715 'text with markup 4|...|1' => [
716 '<strong><a href="mailto:kasper@typo3.org">Kasp...</a>'
721 'text with markup; 11|...|1' => [
722 '<strong><a href="mailto:kasper@typo3.org">Kasper...</a>'
727 'text with markup; 13|...|1' => [
728 '<strong><a href="mailto:kasper@typo3.org">Kasper...</a>'
733 'text with markup; 14|...|1' => [
734 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk'
735 . chr(229) .
'rh' . chr(248) .
'j</a>...</strong>',
739 'text with markup; 15|...|1' => [
740 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk'
741 . chr(229) .
'rh' . chr(248) .
'j</a>...</strong>',
745 'text with markup; 29|...|1' => [
746 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk'
747 . chr(229) .
'rh' . chr(248) .
'j</a> implemented</strong>...',
751 'text with markup; -66|...|1' => [
752 '<strong><a href="mailto:kasper@typo3.org">...Sk' . chr(229)
753 .
'rh' . chr(248) .
'j</a> implemented</strong> the original v'
754 .
'ersion of the crop function.',
758 'text with entities 9|...' => [
763 'text with entities 10|...' => [
764 'Kasper Skå...',
768 'text with entities 11|...' => [
769 'Kasper Skår...',
773 'text with entities 13|...' => [
774 'Kasper Skårhø...',
778 'text with entities 14|...' => [
779 'Kasper Skårhøj...',
783 'text with entities 15|...' => [
784 'Kasper Skårhøj ...',
788 'text with entities 16|...' => [
789 'Kasper Skårhøj i...',
793 'text with entities -57|...' => [
794 '...j implemented the; original version of the crop function.',
798 'text with entities -58|...' => [
799 '...øj implemented the; original version of the crop '
804 'text with entities -59|...' => [
805 '...høj implemented the; original version of the crop '
810 'text with entities 4|...|1' => [
815 'text with entities 9|...|1' => [
820 'text with entities 10|...|1' => [
825 'text with entities 11|...|1' => [
830 'text with entities 13|...|1' => [
835 'text with entities 14|...|1' => [
836 'Kasper Skårhøj...',
840 'text with entities 15|...|1' => [
841 'Kasper Skårhøj...',
845 'text with entities 16|...|1' => [
846 'Kasper Skårhøj...',
850 'text with entities -57|...|1' => [
851 '...implemented the; original version of the crop function.',
855 'text with entities -58|...|1' => [
856 '...implemented the; original version of the crop function.',
860 'text with entities -59|...|1' => [
861 '...implemented the; original version of the crop function.',
865 'text with dash in html-element 28|...|1' => [
866 'Some text with a link to <link email.address@example.org - '
867 .
'mail "Open email window">my...</link>',
868 'Some text with a link to <link email.address@example.org - m'
869 .
'ail "Open email window">my email.address@example.org<'
870 .
'/link> and text after it',
873 'html elements with dashes in attributes' => [
874 '<em data-foo="x">foobar</em>foo',
875 '<em data-foo="x">foobar</em>foobaz',
878 'html elements with iframe embedded 24|...|1' => [
879 'Text with iframe <iframe src="//what.ever/"></iframe> and...',
880 'Text with iframe <iframe src="//what.ever/">'
881 .
'</iframe> and text after it',
884 'html elements with script tag embedded 24|...|1' => [
885 'Text with script <script>alert(\'foo\');</script> and...',
886 'Text with script <script>alert(\'foo\');</script> '
887 .
'and text after it',
890 'text with linebreaks' => [
891 "Lorem ipsum dolor sit amet,\nconsetetur sadipscing elitr,\ns"
892 .
'ed diam nonumy eirmod tempor invidunt ut labore e'
909 public function cropHTML(
string $expect,
string $content,
string $conf): void
914 $this->subject->cropHTML($content, $conf)
927 'down' => [1.0, 1.11, []],
928 'up' => [2.0, 1.51, []],
929 'rounds up from x.50' => [2.0, 1.50, []],
930 'down with decimals' => [0.12, 0.1231, [
'decimals' => 2]],
931 'up with decimals' => [0.13, 0.1251, [
'decimals' => 2]],
932 'ceil' => [1.0, 0.11, [
'roundType' =>
'ceil']],
933 'ceil does not accept decimals' => [
937 'roundType' =>
'ceil',
941 'floor' => [2.0, 2.99, [
'roundType' =>
'floor']],
942 'floor does not accept decimals' => [
946 'roundType' =>
'floor',
950 'round, down' => [1.0, 1.11, [
'roundType' =>
'round']],
951 'round, up' => [2.0, 1.55, [
'roundType' =>
'round']],
952 'round does accept decimals' => [
956 'roundType' =>
'round',
961 'emtpy string' => [0.0,
'', []],
962 'word string' => [0.0,
'word', []],
963 'float string' => [1.0,
'1.123456789', []],
965 'null' => [0.0,
null, []],
966 'false' => [0.0,
false, []],
967 'true' => [1.0,
true, []]
988 public function round(
float $expect, $content, array $conf): void
992 $this->subject->_call(
'round', $content, $conf)
1001 $stdWrapConfiguration = [
1002 'noTrimWrap' =>
'|| 123|',
1004 'wrap' =>
'<b>|</b>'
1009 $this->subject->stdWrap(
'Test', $stdWrapConfiguration)
1018 $stdWrapConfiguration = [
1021 'data' =>
'register:Counter'
1024 'append' =>
'LOAD_REGISTER',
1027 'prioriCalc' =>
'intval',
1028 'cObject' =>
'TEXT',
1030 'data' =>
'register:Counter',
1039 $this->subject->stdWrap(
'Counter:', $stdWrapConfiguration)
1051 'testing decimals' => [
1056 'testing decimals with input as string' => [
1061 'testing dec_point' => [
1064 [
'decimals' => 1,
'dec_point' =>
',']
1066 'testing thousands_sep' => [
1071 'thousands_sep.' => [
'char' => 46]
1074 'testing mixture' => [
1079 'dec_point.' => [
'char' => 44],
1080 'thousands_sep.' => [
'char' => 46]
1095 public function numberFormat(
string $expects, $content, array $conf): void
1099 $this->subject->numberFormat($content, $conf)
1111 'multiple replacements, including regex' => [
1112 'There is an animal, an animal and an animal around the block! Yeah!',
1113 'There_is_a_cat,_a_dog_and_a_tiger_in_da_hood!_Yeah!',
1117 'replace.' => [
'char' =>
'32']
1120 'search' =>
'in da hood',
1121 'replace' =>
'around the block'
1124 'search' =>
'#a (Cat|Dog|Tiger)#i',
1125 'replace' =>
'an animal',
1130 'replacement with optionSplit, normal pattern' => [
1131 'There1is2a3cat,3a3dog3and3a3tiger3in3da3hood!3Yeah!',
1132 'There_is_a_cat,_a_dog_and_a_tiger_in_da_hood!_Yeah!',
1136 'replace' =>
'1 || 2 || 3',
1137 'useOptionSplitReplace' =>
'1',
1142 'replacement with optionSplit, using regex' => [
1143 'There is a tiny cat, a midsized dog and a big tiger in da hood! Yeah!',
1144 'There is a cat, a dog and a tiger in da hood! Yeah!',
1147 'search' =>
'#(a) (Cat|Dog|Tiger)#i',
1148 'replace' =>
'${1} tiny ${2} || ${1} midsized ${2} || ${1} big ${2}',
1149 'useOptionSplitReplace' =>
'1',
1166 public function replacement(
string $expects,
string $content, array $conf): void
1170 $this->subject->_call(
'replacement', $content, $conf)
1185 ' min| hrs| days| yrs',
1190 ' min| hrs| days| yrs',
1195 ' min| hrs| days| yrs',
1197 'day with provided singular labels' => [
1200 ' min| hrs| days| yrs| min| hour| day| year',
1205 ' min| hrs| days| yrs',
1207 'different labels' => [
1210 ' Minutes| Hrs| Days| Yrs',
1212 'negative values' => [
1215 ' min| hrs| days| yrs',
1217 'default label values for wrong label input' => [
1222 'default singular label values for wrong label input' => [
1239 public function calcAge(
string $expect,
int $timestamp,
string $labels): void
1243 $this->subject->calcAge($timestamp, $labels)
1253 'Prevent silent bool conversion' => [
1274 $this->assertSame($expectation, $this->subject->stdWrap($content, $configuration));
1285 'sub -1' => [
'g',
'substring',
'-1'],
1286 'sub -1,0' => [
'g',
'substring',
'-1,0'],
1287 'sub -1,-1' => [
'',
'substring',
'-1,-1'],
1288 'sub -1,1' => [
'g',
'substring',
'-1,1'],
1289 'sub 0' => [
'substring',
'substring',
'0'],
1290 'sub 0,0' => [
'substring',
'substring',
'0,0'],
1291 'sub 0,-1' => [
'substrin',
'substring',
'0,-1'],
1292 'sub 0,1' => [
's',
'substring',
'0,1'],
1293 'sub 1' => [
'ubstring',
'substring',
'1'],
1294 'sub 1,0' => [
'ubstring',
'substring',
'1,0'],
1295 'sub 1,-1' => [
'ubstrin',
'substring',
'1,-1'],
1296 'sub 1,1' => [
'u',
'substring',
'1,1'],
1297 'sub' => [
'substring',
'substring',
''],
1310 public function substring(
string $expect,
string $content,
string $conf): void
1312 $this->assertSame($expect, $this->subject->substring($content, $conf));
1325 'Value in get-data' => [
'onlyInGet',
'GetValue'],
1326 'Value in post-data' => [
'onlyInPost',
'PostValue'],
1327 'Value in post-data overriding get-data' => [
'inGetAndPost',
'ValueInPost'],
1342 'onlyInGet' =>
'GetValue',
1343 'inGetAndPost' =>
'ValueInGet',
1346 'onlyInPost' =>
'PostValue',
1347 'inGetAndPost' =>
'ValueInPost',
1349 $this->assertEquals($expectedValue, $this->subject->getData(
'gp:' . $key));
1359 $this->assertEquals(
$GLOBALS[
'TSFE']->metaCharset, $this->subject->getData(
'tsfe:metaCharset'));
1369 $envName = $this->getUniqueId(
'frontendtest');
1370 $value = $this->getUniqueId(
'someValue');
1371 putenv($envName .
'=' . $value);
1372 $this->assertEquals($value, $this->subject->getData(
'getenv:' . $envName));
1382 $this->subject->expects($this->once())->method(
'getEnvironmentVariable')
1383 ->with($this->equalTo(
'SCRIPT_FILENAME'))->will($this->returnValue(
'dummyPath'));
1384 $this->assertEquals(
'dummyPath', $this->subject->getData(
'getindpenv:SCRIPT_FILENAME'));
1395 $value =
'someValue';
1396 $field = [$key => $value];
1398 $this->assertEquals($value, $this->subject->getData(
'field:' . $key, $field));
1409 $key =
'somekey|level1|level2';
1410 $value =
'somevalue';
1411 $field = [
'somekey' => [
'level1' => [
'level2' =>
'somevalue']]];
1413 $this->assertEquals($value, $this->subject->getData(
'field:' . $key, $field));
1423 $uid = $this->getUniqueId();
1424 $file = $this->createMock(File::class);
1425 $file->expects($this->once())->method(
'getUid')->will($this->returnValue($uid));
1426 $this->subject->setCurrentFile($file);
1427 $this->assertEquals($uid, $this->subject->getData(
'file:current:uid'));
1437 $key = $this->getUniqueId(
'someKey');
1438 $value = $this->getUniqueId(
'someValue');
1439 $this->subject->parameters[$key] = $value;
1441 $this->assertEquals($value, $this->subject->getData(
'parameters:' . $key));
1451 $key = $this->getUniqueId(
'someKey');
1452 $value = $this->getUniqueId(
'someValue');
1453 $GLOBALS[
'TSFE']->register[$key] = $value;
1455 $this->assertEquals($value, $this->subject->getData(
'register:' . $key));
1465 $frontendUser = $this->getMockBuilder(FrontendUserAuthentication::class)
1466 ->setMethods([
'getSessionData'])
1468 $frontendUser->expects($this->once())->method(
'getSessionData')->with(
'myext')->willReturn([
1473 $GLOBALS[
'TSFE']->fe_user = $frontendUser;
1475 $this->assertEquals(42, $this->subject->getData(
'session:myext|mydata|someValue'));
1486 0 => [
'uid' => 1,
'title' =>
'title1'],
1487 1 => [
'uid' => 2,
'title' =>
'title2'],
1488 2 => [
'uid' => 3,
'title' =>
'title3'],
1491 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline;
1492 $this->assertEquals(2, $this->subject->getData(
'level'));
1502 $this->assertEquals(
$GLOBALS[
'TSFE']->metaCharset, $this->subject->getData(
'global:TSFE|metaCharset'));
1513 0 => [
'uid' => 1,
'title' =>
'title1'],
1514 1 => [
'uid' => 2,
'title' =>
'title2'],
1515 2 => [
'uid' => 3,
'title' =>
''],
1518 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline;
1519 $this->assertEquals(
'', $this->subject->getData(
'leveltitle:-1'));
1521 $this->assertEquals(
'title2', $this->subject->getData(
'leveltitle:-1,slide'));
1532 0 => [
'uid' => 1,
'title' =>
'title1',
'media' =>
'media1'],
1533 1 => [
'uid' => 2,
'title' =>
'title2',
'media' =>
'media2'],
1534 2 => [
'uid' => 3,
'title' =>
'title3',
'media' =>
''],
1537 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline;
1538 $this->assertEquals(
'', $this->subject->getData(
'levelmedia:-1'));
1540 $this->assertEquals(
'media2', $this->subject->getData(
'levelmedia:-1,slide'));
1551 0 => [
'uid' => 1,
'title' =>
'title1'],
1552 1 => [
'uid' => 2,
'title' =>
'title2'],
1553 2 => [
'uid' => 3,
'title' =>
'title3'],
1556 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline;
1557 $this->assertEquals(3, $this->subject->getData(
'leveluid:-1'));
1559 $this->assertEquals(3, $this->subject->getData(
'leveluid:-1,slide'));
1570 0 => [
'uid' => 1,
'title' =>
'title1',
'testfield' =>
'field1'],
1571 1 => [
'uid' => 2,
'title' =>
'title2',
'testfield' =>
'field2'],
1572 2 => [
'uid' => 3,
'title' =>
'title3',
'testfield' =>
''],
1575 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline;
1576 $this->assertEquals(
'', $this->subject->getData(
'levelfield:-1,testfield'));
1577 $this->assertEquals(
'field2', $this->subject->getData(
'levelfield:-1,testfield,slide'));
1588 0 => [
'uid' => 1,
'title' =>
'title1',
'testfield' =>
'field1'],
1591 0 => [
'uid' => 1,
'title' =>
'title1',
'testfield' =>
'field1'],
1592 1 => [
'uid' => 2,
'title' =>
'title2',
'testfield' =>
'field2'],
1593 2 => [
'uid' => 3,
'title' =>
'title3',
'testfield' =>
'field3'],
1596 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline1;
1597 $GLOBALS[
'TSFE']->rootLine = $rootline2;
1598 $this->assertEquals(
'field2', $this->subject->getData(
'fullrootline:-1,testfield'));
1609 $defaultFormat =
'd/m Y';
1611 $this->assertEquals(date($format,
$GLOBALS[
'EXEC_TIME']), $this->subject->getData(
'date:' . $format));
1612 $this->assertEquals(date($defaultFormat,
$GLOBALS[
'EXEC_TIME']), $this->subject->getData(
'date'));
1624 $this->assertEquals($uid, $this->subject->getData(
'page:uid'));
1634 $key = $this->getUniqueId(
'someKey');
1635 $value = $this->getUniqueId(
'someValue');
1636 $this->subject->data[$key] = $value;
1637 $this->subject->currentValKey = $key;
1638 $this->assertEquals($value, $this->subject->getData(
'current'));
1648 $dummyRecord = [
'uid' => 5,
'title' =>
'someTitle'];
1650 $GLOBALS[
'TSFE']->sys_page->expects($this->atLeastOnce())->method(
'getRawRecord')->with(
1653 )->will($this->returnValue($dummyRecord));
1654 $this->assertEquals($dummyRecord[
'title'], $this->subject->getData(
'db:tt_content:106:title'));
1664 $key = $this->getUniqueId(
'someKey');
1665 $value = $this->getUniqueId(
'someValue');
1666 $GLOBALS[
'TSFE']->expects($this->once())->method(
'sL')->with(
'LLL:' . $key)->will($this->returnValue($value));
1667 $this->assertEquals($value, $this->subject->getData(
'lll:' . $key));
1677 $filenameIn =
'typo3/sysext/frontend/Public/Icons/Extension.svg';
1678 $this->assertEquals($filenameIn, $this->subject->getData(
'path:' . $filenameIn));
1692 GeneralUtility::setSingletonInstance(Context::class, $context);
1693 $this->assertEquals(3, $this->subject->getData(
'context:workspace:id'));
1694 $this->assertEquals(
'0,-1', $this->subject->getData(
'context:frontend.user:groupIds'));
1695 $this->assertEquals(
false, $this->subject->getData(
'context:frontend.user:isLoggedIn'));
1696 $this->assertEquals(
false, $this->subject->getData(
'context:frontend.user:foozball'));
1706 $site =
new Site(
'my-site', 123, [
1707 'base' =>
'http://example.com',
1714 $serverRequest = $this->prophesize(ServerRequestInterface::class);
1715 $serverRequest->getAttribute(
'site')->willReturn($site);
1716 $GLOBALS[
'TYPO3_REQUEST'] = $serverRequest->reveal();
1717 $this->assertEquals(
'http://example.com', $this->subject->getData(
'site:base'));
1718 $this->assertEquals(
'yeah', $this->subject->getData(
'site:custom.config.nested'));
1728 $cacheManagerProphecy = $this->prophesize(CacheManager::class);
1729 $cacheProphecy = $this->prophesize(CacheFrontendInterface::class);
1730 $cacheManagerProphecy->getCache(
'cache_core')->willReturn($cacheProphecy->reveal());
1731 GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
1732 putenv(
'LOCAL_DEVELOPMENT=1');
1734 $site =
new Site(
'my-site', 123, [
1735 'base' =>
'http://prod.com',
1738 'base' =>
'http://staging.com',
1739 'condition' =>
'applicationContext == "Production/Staging"'
1742 'base' =>
'http://dev.com',
1743 'condition' =>
'getenv("LOCAL_DEVELOPMENT") == 1'
1748 $serverRequest = $this->prophesize(ServerRequestInterface::class);
1749 $serverRequest->getAttribute(
'site')->willReturn($site);
1750 $GLOBALS[
'TYPO3_REQUEST'] = $serverRequest->reveal();
1751 $this->assertEquals(
'http://dev.com', $this->subject->getData(
'site:base'));
1764 'locale' =>
'de_DE',
1765 'title' =>
'languageTitle',
1766 'navigationTitle' =>
'German'
1768 $language = $site->getLanguageById(1);
1769 $serverRequest = $this->prophesize(ServerRequestInterface::class);
1770 $serverRequest->getAttribute(
'language')->willReturn($language);
1771 $GLOBALS[
'TYPO3_REQUEST'] = $serverRequest->reveal();
1772 $this->assertEquals(
'German', $this->subject->getData(
'siteLanguage:navigationTitle'));
1782 $recordNumber = mt_rand();
1783 $this->subject->parentRecordNumber = $recordNumber;
1784 $this->assertEquals($recordNumber, $this->subject->getData(
'cobj:parentRecordNumber'));
1795 0 => [
'uid' => 1,
'title' =>
'title1'],
1796 1 => [
'uid' => 2,
'title' =>
'title2'],
1797 2 => [
'uid' => 3,
'title' =>
''],
1799 $expectedResult =
'array(3items)0=>array(2items)uid=>1(integer)title=>"title1"(6chars)1=>array(2items)uid=>2(integer)title=>"title2"(6chars)2=>array(2items)uid=>3(integer)title=>""(0chars)';
1800 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline;
1803 $result = $this->subject->getData(
'debug:rootLine');
1804 $cleanedResult = str_replace([
"\r",
"\n",
"\t",
' '],
'', $result);
1806 $this->assertEquals($expectedResult, $cleanedResult);
1817 0 => [
'uid' => 1,
'title' =>
'title1'],
1818 1 => [
'uid' => 2,
'title' =>
'title2'],
1819 2 => [
'uid' => 3,
'title' =>
''],
1821 $expectedResult =
'array(3items)0=>array(2items)uid=>1(integer)title=>"title1"(6chars)1=>array(2items)uid=>2(integer)title=>"title2"(6chars)2=>array(2items)uid=>3(integer)title=>""(0chars)';
1822 $GLOBALS[
'TSFE']->rootLine = $rootline;
1825 $result = $this->subject->getData(
'debug:fullRootLine');
1826 $cleanedResult = str_replace([
"\r",
"\n",
"\t",
' '],
'', $result);
1828 $this->assertEquals($expectedResult, $cleanedResult);
1838 $key = $this->getUniqueId(
'someKey');
1839 $value = $this->getUniqueId(
'someValue');
1840 $this->subject->data = [$key => $value];
1842 $expectedResult =
'array(1item)' . $key .
'=>"' . $value .
'"(' . strlen($value) .
'chars)';
1845 $result = $this->subject->getData(
'debug:data');
1846 $cleanedResult = str_replace([
"\r",
"\n",
"\t",
' '],
'', $result);
1848 $this->assertEquals($expectedResult, $cleanedResult);
1858 $key = $this->getUniqueId(
'someKey');
1859 $value = $this->getUniqueId(
'someValue');
1860 $GLOBALS[
'TSFE']->register = [$key => $value];
1862 $expectedResult =
'array(1item)' . $key .
'=>"' . $value .
'"(' . strlen($value) .
'chars)';
1865 $result = $this->subject->getData(
'debug:register');
1866 $cleanedResult = str_replace([
"\r",
"\n",
"\t",
' '],
'', $result);
1868 $this->assertEquals($expectedResult, $cleanedResult);
1879 $GLOBALS[
'TSFE']->page = [
'uid' => $uid];
1881 $expectedResult =
'array(1item)uid=>' . $uid .
'(integer)';
1884 $result = $this->subject->getData(
'debug:page');
1885 $cleanedResult = str_replace([
"\r",
"\n",
"\t",
' '],
'', $result);
1887 $this->assertEquals($expectedResult, $cleanedResult);
1895 $aTagParams = $this->subject->getATagParams([
'ATagParams' =>
'data-test="testdata"']);
1896 $this->assertEquals(
' data-test="testdata"', $aTagParams);
1904 $GLOBALS[
'TSFE']->ATagParams =
'data-global="dataglobal"';
1905 $aTagParams = $this->subject->getATagParams([
'ATagParams' =>
'data-test="testdata"']);
1906 $this->assertEquals(
' data-global="dataglobal" data-test="testdata"', $aTagParams);
1916 $aTagParams = $this->subject->getATagParams([
'ATagParams' =>
'']);
1917 $this->assertEquals(
'', $aTagParams);
1929 [
'fooo', [
'foo' =>
'bar']]
1943 $defaultImgTagTemplate =
'<img src="###SRC###" width="###WIDTH###" height="###HEIGHT###" ###PARAMS### ###ALTPARAMS### ###BORDER######SELFCLOSINGTAGSLASH###>';
1944 $result = $this->subject->getImageTagTemplate($key, $configuration);
1945 $this->assertEquals($result, $defaultImgTagTemplate);
1959 'element' =>
'<img src="###SRC###" srcset="###SOURCES###" ###PARAMS### ###ALTPARAMS### ###FOOBAR######SELFCLOSINGTAGSLASH###>'
1963 '<img src="###SRC###" srcset="###SOURCES###" ###PARAMS### ###ALTPARAMS### ###FOOBAR######SELFCLOSINGTAGSLASH###>'
1980 $result = $this->subject->getImageTagTemplate($key, $configuration);
1981 $this->assertEquals($result, $expectation);
1991 [
'foo',
null,
null],
1992 [
'foo', [
'sourceCollection.' => 1],
'bar']
2010 $result = $this->subject->getImageSourceCollection($layoutKey, $configuration, $file);
2011 $this->assertSame($result,
'');
2022 $cObj = $this->getMockBuilder(ContentObjectRenderer::class)
2023 ->setMethods([
'stdWrap',
'getImgResource'])
2026 $cObj->start([],
'tt_content');
2028 $layoutKey =
'test';
2031 'layoutKey' =>
'test',
2034 'element' =>
'<img ###SRC### ###SRCCOLLECTION### ###SELFCLOSINGTAGSLASH###>',
2035 'source' =>
'---###SRC###---'
2038 'sourceCollection.' => [
2045 $file =
'testImageName';
2049 ->expects($this->any())
2051 ->will($this->returnArgument(0));
2055 ->expects($this->exactly(1))
2056 ->method(
'getImgResource')
2057 ->with($this->equalTo(
'testImageName'))
2058 ->will($this->returnValue([100, 100,
null,
'bar']));
2060 $result = $cObj->getImageSourceCollection($layoutKey, $configuration, $file);
2062 $this->assertEquals(
'---bar---', $result);
2073 $sourceCollectionArray = [
2076 'srcsetCandidate' =>
'600w',
2077 'mediaQuery' =>
'(max-device-width: 600px)',
2078 'dataKey' =>
'small',
2081 'if.directReturn' => 0,
2083 'pixelDensity' =>
'2',
2084 'srcsetCandidate' =>
'600w 2x',
2085 'mediaQuery' =>
'(max-device-width: 600px) AND (min-resolution: 192dpi)',
2086 'dataKey' =>
'smallRetina',
2093 'layoutKey' =>
'default',
2096 'element' =>
'<img src="###SRC###" width="###WIDTH###" height="###HEIGHT###" ###PARAMS### ###ALTPARAMS### ###BORDER######SELFCLOSINGTAGSLASH###>',
2100 'sourceCollection.' => $sourceCollectionArray
2117 $cObj = $this->getMockBuilder(ContentObjectRenderer::class)
2118 ->setMethods([
'stdWrap',
'getImgResource'])
2121 $cObj->start([],
'tt_content');
2123 $file =
'testImageName';
2127 ->expects($this->any())
2129 ->will($this->returnArgument(0));
2131 $result = $cObj->getImageSourceCollection($layoutKey, $configuration, $file);
2133 $this->assertEmpty($result);
2144 $sourceCollectionArray = [
2147 'srcsetCandidate' =>
'600w',
2148 'mediaQuery' =>
'(max-device-width: 600px)',
2149 'dataKey' =>
'small',
2152 'if.directReturn' => 1,
2154 'pixelDensity' =>
'2',
2155 'srcsetCandidate' =>
'600w 2x',
2156 'mediaQuery' =>
'(max-device-width: 600px) AND (min-resolution: 192dpi)',
2157 'dataKey' =>
'smallRetina',
2164 'layoutKey' =>
'srcset',
2167 'element' =>
'<img src="###SRC###" srcset="###SOURCECOLLECTION###" ###PARAMS### ###ALTPARAMS######SELFCLOSINGTAGSLASH###>',
2168 'source' =>
'|*|###SRC### ###SRCSETCANDIDATE###,|*|###SRC### ###SRCSETCANDIDATE###'
2171 'sourceCollection.' => $sourceCollectionArray
2174 'bar-file.jpg 600w,bar-file.jpg 600w 2x',
2179 'layoutKey' =>
'picture',
2182 'element' =>
'<picture>###SOURCECOLLECTION###<img src="###SRC###" ###PARAMS### ###ALTPARAMS######SELFCLOSINGTAGSLASH###></picture>',
2183 'source' =>
'<source src="###SRC###" media="###MEDIAQUERY###"###SELFCLOSINGTAGSLASH###>'
2186 'sourceCollection.' => $sourceCollectionArray,
2189 '<source src="bar-file.jpg" media="(max-device-width: 600px)" /><source src="bar-file.jpg" media="(max-device-width: 600px) AND (min-resolution: 192dpi)" />',
2194 'layoutKey' =>
'picture',
2197 'element' =>
'<picture>###SOURCECOLLECTION###<img src="###SRC###" ###PARAMS### ###ALTPARAMS######SELFCLOSINGTAGSLASH###></picture>',
2198 'source' =>
'<source src="###SRC###" media="###MEDIAQUERY###"###SELFCLOSINGTAGSLASH###>'
2201 'sourceCollection.' => $sourceCollectionArray,
2204 '<source src="bar-file.jpg" media="(max-device-width: 600px)"><source src="bar-file.jpg" media="(max-device-width: 600px) AND (min-resolution: 192dpi)">',
2209 'layoutKey' =>
'data',
2212 'element' =>
'<img src="###SRC###" ###SOURCECOLLECTION### ###PARAMS### ###ALTPARAMS######SELFCLOSINGTAGSLASH###>',
2213 'source' =>
'data-###DATAKEY###="###SRC###"'
2216 'sourceCollection.' => $sourceCollectionArray
2219 'data-small="bar-file.jpg"data-smallRetina="bar-file.jpg"',
2241 $cObj = $this->getMockBuilder(ContentObjectRenderer::class)
2242 ->setMethods([
'stdWrap',
'getImgResource'])
2245 $cObj->start([],
'tt_content');
2247 $file =
'testImageName';
2249 $GLOBALS[
'TSFE']->xhtmlDoctype = $xhtmlDoctype;
2253 ->expects($this->any())
2255 ->will($this->returnArgument(0));
2259 ->expects($this->exactly(2))
2260 ->method(
'getImgResource')
2261 ->with($this->equalTo(
'testImageName'))
2262 ->will($this->returnValue([100, 100,
null,
'bar-file.jpg']));
2264 $result = $cObj->getImageSourceCollection($layoutKey, $configuration, $file);
2266 $this->assertEquals($expectedHtml, $result);
2276 $this->subject = $this->getAccessibleMock(
2277 ContentObjectRenderer::class,
2278 [
'getResourceFactory',
'stdWrap',
'getImgResource']
2280 $this->subject->start([],
'tt_content');
2283 $this->subject->expects($this->any())
2285 ->will($this->returnArgument(0));
2287 $this->subject->expects($this->any())
2288 ->method(
'getImgResource')
2289 ->will($this->returnValue([100, 100,
null,
'bar-file.jpg']));
2291 $resourceFactory = $this->createMock(ResourceFactory::class);
2292 $this->subject->expects($this->any())->method(
'getResourceFactory')->will($this->returnValue($resourceFactory));
2294 $className = $this->getUniqueId(
'tx_coretest_getImageSourceCollectionHookCalled');
2295 $getImageSourceCollectionHookMock = $this->getMockBuilder(
2296 ContentObjectOneSourceCollectionHookInterface::class
2298 ->setMethods([
'getOneSourceCollection'])
2299 ->setMockClassName($className)
2301 GeneralUtility::addInstance($className, $getImageSourceCollectionHookMock);
2302 $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'getImageSourceCollection'][] = $className;
2304 $getImageSourceCollectionHookMock
2305 ->expects($this->exactly(1))
2306 ->method(
'getOneSourceCollection')
2307 ->will($this->returnCallback([$this,
'isGetOneSourceCollectionCalledCallback']));
2310 'layoutKey' =>
'data',
2313 'element' =>
'<img src="###SRC###" ###SOURCECOLLECTION### ###PARAMS### ###ALTPARAMS######SELFCLOSINGTAGSLASH###>',
2314 'source' =>
'data-###DATAKEY###="###SRC###"'
2317 'sourceCollection.' => [
2320 'srcsetCandidate' =>
'600w',
2321 'mediaQuery' =>
'(max-device-width: 600px)',
2322 'dataKey' =>
'small',
2327 $result = $this->subject->getImageSourceCollection(
'data', $configuration, $this->getUniqueId(
'testImage-'));
2329 $this->assertSame($result,
'isGetOneSourceCollectionCalledCallback');
2343 array $sourceRenderConfiguration,
2344 array $sourceConfiguration,
2345 $oneSourceCollection,
2348 $this->assertTrue(is_array($sourceRenderConfiguration));
2349 $this->assertTrue(is_array($sourceConfiguration));
2350 return 'isGetOneSourceCollectionCalledCallback';
2358 $this->expectException(\LogicException::class);
2359 $this->expectExceptionCode(1414513947);
2361 $this->subject->render($contentObjectFixture, []);
2369 $backupApplicationContext = GeneralUtility::getApplicationContext();
2373 $this->subject->render($contentObjectFixture, []);
2386 'exceptionHandler' =>
'1'
2388 $this->subject->render($contentObjectFixture, $configuration);
2398 $this->frontendControllerMock->config[
'config'][
'contentObjectExceptionHandler'] =
'1';
2399 $this->subject->render($contentObjectFixture, []);
2408 $this->expectException(\LogicException::class);
2409 $this->expectExceptionCode(1414513947);
2410 $this->frontendControllerMock->config[
'config'][
'contentObjectExceptionHandler'] =
'1';
2412 'exceptionHandler' =>
'0'
2414 $this->subject->render($contentObjectFixture, $configuration);
2425 'exceptionHandler' =>
'1',
2426 'exceptionHandler.' => [
2427 'errorMessage' =>
'New message for testing',
2431 $this->assertSame(
'New message for testing', $this->subject->render($contentObjectFixture, $configuration));
2441 $this->frontendControllerMock
2442 ->config[
'config'][
'contentObjectExceptionHandler.'] = [
2443 'errorMessage' =>
'Global message for testing',
2446 'exceptionHandler' =>
'1',
2447 'exceptionHandler.' => [
2448 'errorMessage' =>
'New message for testing',
2452 $this->assertSame(
'New message for testing', $this->subject->render($contentObjectFixture, $configuration));
2463 'exceptionHandler' =>
'1',
2464 'exceptionHandler.' => [
2465 'ignoreCodes.' => [
'10.' =>
'1414513947'],
2468 $this->expectException(\LogicException::class);
2469 $this->expectExceptionCode(1414513947);
2470 $this->subject->render($contentObjectFixture, $configuration);
2478 $contentObjectFixture = $this->getMockBuilder(AbstractContentObject::class)
2479 ->setConstructorArgs([$this->subject])
2481 $contentObjectFixture->expects($this->once())
2483 ->willReturnCallback(
function () {
2484 throw new \LogicException(
'Exception during rendering', 1414513947);
2486 return $contentObjectFixture;
2498 'keep' =>
'{$styles.content.links.keep}',
2511 'data' =>
'parameters : allParams',
2520 'allowTags' =>
'a, abbr, acronym, address, article, aside, b, bdo, big, blockquote, br, caption, center, cite, code, col, colgroup, dd, del, dfn, dl, div, dt, em, font, footer, header, h1, h2, h3, h4, h5, h6, hr, i, img, ins, kbd, label, li, link, meta, nav, ol, p, pre, q, samp, sdfield, section, small, span, strike, strong, style, sub, sup, table, thead, tbody, tfoot, td, th, tr, title, tt, u, ul, var',
2522 'sword' =>
'<span class="csc-sword">|</span>',
2524 'nonTypoTagStdWrap.' => [
2525 'HTMLparser' =>
'1',
2527 'keepNonMatchedTags' =>
'1',
2528 'htmlSpecialChars' =>
'2',
2543 'directImageLink' =>
false,
2544 'parameter' =>
'http://typo3.org',
2546 '<a href="http://typo3.org">TYPO3</a>',
2548 'Link to url without schema' => [
2551 'directImageLink' =>
false,
2552 'parameter' =>
'typo3.org',
2554 '<a href="http://typo3.org">TYPO3</a>',
2556 'Link to url without link text' => [
2559 'directImageLink' =>
false,
2560 'parameter' =>
'http://typo3.org',
2562 '<a href="http://typo3.org">http://typo3.org</a>',
2564 'Link to url with attributes' => [
2567 'parameter' =>
'http://typo3.org',
2568 'ATagParams' =>
'class="url-class"',
2569 'extTarget' =>
'_blank',
2570 'title' =>
'Open new window',
2572 '<a href="http://typo3.org" title="Open new window" target="_blank" class="url-class">TYPO3</a>',
2574 'Link to url with attributes in parameter' => [
2577 'parameter' =>
'http://typo3.org _blank url-class "Open new window"',
2579 '<a href="http://typo3.org" title="Open new window" target="_blank" class="url-class">TYPO3</a>',
2581 'Link to url with script tag' => [
2584 'directImageLink' =>
false,
2585 'parameter' =>
'http://typo3.org<script>alert(123)</script>',
2587 '<a href="http://typo3.org<script>alert(123)</script>">http://typo3.org<script>alert(123)</script></a>',
2589 'Link to email address' => [
2592 'parameter' =>
'foo@bar.org',
2594 '<a href="mailto:foo@bar.org">Email address</a>',
2596 'Link to email address without link text' => [
2599 'parameter' =>
'foo@bar.org',
2601 '<a href="mailto:foo@bar.org">foo@bar.org</a>',
2603 'Link to email with attributes' => [
2606 'parameter' =>
'foo@bar.org',
2607 'ATagParams' =>
'class="email-class"',
2608 'title' =>
'Write an email',
2610 '<a href="mailto:foo@bar.org" title="Write an email" class="email-class">Email address</a>',
2612 'Link to email with attributes in parameter' => [
2615 'parameter' =>
'foo@bar.org - email-class "Write an email"',
2617 '<a href="mailto:foo@bar.org" title="Write an email" class="email-class">Email address</a>',
2631 $packageManagerMock = $this->getMockBuilder(PackageManager::class)
2632 ->disableOriginalConstructor()
2634 $templateServiceObjectMock = $this->getMockBuilder(TemplateService::class)
2635 ->setConstructorArgs([
null, $packageManagerMock])
2636 ->setMethods([
'dummy'])
2638 $templateServiceObjectMock->setup = [
2643 $typoScriptFrontendControllerMockObject = $this->createMock(TypoScriptFrontendController::class);
2644 $typoScriptFrontendControllerMockObject->config = [
2647 $typoScriptFrontendControllerMockObject->tmpl = $templateServiceObjectMock;
2648 $GLOBALS[
'TSFE'] = $typoScriptFrontendControllerMockObject;
2649 $this->subject->_set(
'typoScriptFrontendController', $typoScriptFrontendControllerMockObject);
2651 $this->assertEquals($expectedResult, $this->subject->typoLink($linkText, $configuration));
2670 $typoScript = [
'parameter' => $mailAddress];
2672 $this->assertEquals($expected, $this->subject->typoLink($linkText, $typoScript));
2681 'plain mail without mailto scheme' => [
2683 'spamProtectEmailAddresses' =>
'',
2684 'spamProtectEmailAddresses_atSubst' =>
'',
2685 'spamProtectEmailAddresses_lastDotSubst' =>
'',
2687 'some.body@test.typo3.org',
2688 'some.body@test.typo3.org',
2689 '<a href="mailto:some.body@test.typo3.org">some.body@test.typo3.org</a>',
2691 'plain mail with mailto scheme' => [
2693 'spamProtectEmailAddresses' =>
'',
2694 'spamProtectEmailAddresses_atSubst' =>
'',
2695 'spamProtectEmailAddresses_lastDotSubst' =>
'',
2697 'some.body@test.typo3.org',
2698 'mailto:some.body@test.typo3.org',
2699 '<a href="mailto:some.body@test.typo3.org">some.body@test.typo3.org</a>',
2701 'plain with at and dot substitution' => [
2703 'spamProtectEmailAddresses' =>
'0',
2704 'spamProtectEmailAddresses_atSubst' =>
'(at)',
2705 'spamProtectEmailAddresses_lastDotSubst' =>
'(dot)',
2707 'some.body@test.typo3.org',
2708 'mailto:some.body@test.typo3.org',
2709 '<a href="mailto:some.body@test.typo3.org">some.body@test.typo3.org</a>',
2711 'mono-alphabetic substitution offset +1' => [
2713 'spamProtectEmailAddresses' =>
'1',
2714 'spamProtectEmailAddresses_atSubst' =>
'',
2715 'spamProtectEmailAddresses_lastDotSubst' =>
'',
2717 'some.body@test.typo3.org',
2718 'mailto:some.body@test.typo3.org',
2719 '<a href="javascript:linkTo_UnCryptMailto(%27nbjmup%2Btpnf%5C%2FcpezAuftu%5C%2Fuzqp4%5C%2Fpsh%27);">some.body(at)test.typo3.org</a>',
2721 'mono-alphabetic substitution offset +1 with at substitution' => [
2723 'spamProtectEmailAddresses' =>
'1',
2724 'spamProtectEmailAddresses_atSubst' =>
'@',
2725 'spamProtectEmailAddresses_lastDotSubst' =>
'',
2727 'some.body@test.typo3.org',
2728 'mailto:some.body@test.typo3.org',
2729 '<a href="javascript:linkTo_UnCryptMailto(%27nbjmup%2Btpnf%5C%2FcpezAuftu%5C%2Fuzqp4%5C%2Fpsh%27);">some.body@test.typo3.org</a>',
2731 'mono-alphabetic substitution offset +1 with at and dot substitution' => [
2733 'spamProtectEmailAddresses' =>
'1',
2734 'spamProtectEmailAddresses_atSubst' =>
'(at)',
2735 'spamProtectEmailAddresses_lastDotSubst' =>
'(dot)',
2737 'some.body@test.typo3.org',
2738 'mailto:some.body@test.typo3.org',
2739 '<a href="javascript:linkTo_UnCryptMailto(%27nbjmup%2Btpnf%5C%2FcpezAuftu%5C%2Fuzqp4%5C%2Fpsh%27);">some.body(at)test.typo3(dot)org</a>',
2741 'mono-alphabetic substitution offset -1 with at and dot substitution' => [
2743 'spamProtectEmailAddresses' =>
'-1',
2744 'spamProtectEmailAddresses_atSubst' =>
'(at)',
2745 'spamProtectEmailAddresses_lastDotSubst' =>
'(dot)',
2747 'some.body@test.typo3.org',
2748 'mailto:some.body@test.typo3.org',
2749 '<a href="javascript:linkTo_UnCryptMailto(%27lzhksn9rnld-ancxZsdrs-sxon2-nqf%27);">some.body(at)test.typo3(dot)org</a>',
2751 'mono-alphabetic substitution offset 2 with at and dot substitution and encoded subject' => [
2753 'spamProtectEmailAddresses' =>
'2',
2754 'spamProtectEmailAddresses_atSubst' =>
'(at)',
2755 'spamProtectEmailAddresses_lastDotSubst' =>
'(dot)',
2757 'some.body@test.typo3.org',
2758 'mailto:some.body@test.typo3.org?subject=foo%20bar',
2759 '<a href="javascript:linkTo_UnCryptMailto(%27ocknvq%2Cuqog0dqfaBvguv0varq50qti%3Fuwdlgev%3Dhqq%2542dct%27);">some.body@test.typo3.org</a>',
2761 'entity substitution with at and dot substitution' => [
2763 'spamProtectEmailAddresses' =>
'ascii',
2764 'spamProtectEmailAddresses_atSubst' =>
'',
2765 'spamProtectEmailAddresses_lastDotSubst' =>
'',
2767 'some.body@test.typo3.org',
2768 'mailto:some.body@test.typo3.org',
2769 '<a href="mailto:some.body@test.typo3.org">some.body(at)test.typo3.org</a>',
2771 'entity substitution with at and dot substitution with at and dot substitution' => [
2773 'spamProtectEmailAddresses' =>
'ascii',
2774 'spamProtectEmailAddresses_atSubst' =>
'(at)',
2775 'spamProtectEmailAddresses_lastDotSubst' =>
'(dot)',
2777 'some.body@test.typo3.org',
2778 'mailto:some.body@test.typo3.org',
2779 '<a href="mailto:some.body@test.typo3.org">some.body(at)test.typo3(dot)org</a>',
2793 'directImageLink' =>
false,
2794 'parameter' =>
'fileadmin/foo.bar',
2796 '<a href="fileadmin/foo.bar">My file</a>',
2798 'Link to file without link text' => [
2801 'directImageLink' =>
false,
2802 'parameter' =>
'fileadmin/foo.bar',
2804 '<a href="fileadmin/foo.bar">fileadmin/foo.bar</a>',
2806 'Link to file with attributes' => [
2809 'parameter' =>
'fileadmin/foo.bar',
2810 'ATagParams' =>
'class="file-class"',
2811 'fileTarget' =>
'_blank',
2812 'title' =>
'Title of the file',
2814 '<a href="fileadmin/foo.bar" title="Title of the file" target="_blank" class="file-class">My file</a>',
2816 'Link to file with attributes and additional href' => [
2819 'parameter' =>
'fileadmin/foo.bar',
2820 'ATagParams' =>
'href="foo-bar"',
2821 'fileTarget' =>
'_blank',
2822 'title' =>
'Title of the file',
2824 '<a href="fileadmin/foo.bar" title="Title of the file" target="_blank">My file</a>',
2826 'Link to file with attributes and additional href and class' => [
2829 'parameter' =>
'fileadmin/foo.bar',
2830 'ATagParams' =>
'href="foo-bar" class="file-class"',
2831 'fileTarget' =>
'_blank',
2832 'title' =>
'Title of the file',
2834 '<a href="fileadmin/foo.bar" title="Title of the file" target="_blank" class="file-class">My file</a>',
2836 'Link to file with attributes and additional class and href' => [
2839 'parameter' =>
'fileadmin/foo.bar',
2840 'ATagParams' =>
'class="file-class" href="foo-bar"',
2841 'fileTarget' =>
'_blank',
2842 'title' =>
'Title of the file',
2844 '<a href="fileadmin/foo.bar" title="Title of the file" target="_blank" class="file-class">My file</a>',
2846 'Link to file with attributes and additional class and href and title' => [
2849 'parameter' =>
'fileadmin/foo.bar',
2850 'ATagParams' =>
'class="file-class" href="foo-bar" title="foo-bar"',
2851 'fileTarget' =>
'_blank',
2852 'title' =>
'Title of the file',
2854 '<a href="fileadmin/foo.bar" title="foo-bar" target="_blank" class="file-class">My file</a>',
2856 'Link to file with attributes and empty ATagParams' => [
2859 'parameter' =>
'fileadmin/foo.bar',
2861 'fileTarget' =>
'_blank',
2862 'title' =>
'Title of the file',
2864 '<a href="fileadmin/foo.bar" title="Title of the file" target="_blank">My file</a>',
2866 'Link to file with attributes in parameter' => [
2869 'parameter' =>
'fileadmin/foo.bar _blank file-class "Title of the file"',
2871 '<a href="fileadmin/foo.bar" title="Title of the file" target="_blank" class="file-class">My file</a>',
2873 'Link to file with script tag in name' => [
2876 'directImageLink' =>
false,
2877 'parameter' =>
'fileadmin/<script>alert(123)</script>',
2879 '<a href="fileadmin/<script>alert(123)</script>">fileadmin/<script>alert(123)</script></a>',
2893 $packageManagerMock = $this->getMockBuilder(PackageManager::class)
2894 ->disableOriginalConstructor()
2896 $templateServiceObjectMock = $this->getMockBuilder(TemplateService::class)
2897 ->setConstructorArgs([
null, $packageManagerMock])
2898 ->setMethods([
'dummy'])
2900 $templateServiceObjectMock->setup = [
2905 $typoScriptFrontendControllerMockObject = $this->createMock(TypoScriptFrontendController::class);
2906 $typoScriptFrontendControllerMockObject->config = [
2909 $typoScriptFrontendControllerMockObject->tmpl = $templateServiceObjectMock;
2910 $GLOBALS[
'TSFE'] = $typoScriptFrontendControllerMockObject;
2912 $resourceFactory = $this->prophesize(ResourceFactory::class);
2913 GeneralUtility::setSingletonInstance(ResourceFactory::class, $resourceFactory->reveal());
2915 $this->subject->_set(
'typoScriptFrontendController', $typoScriptFrontendControllerMockObject);
2917 $this->assertEquals($expectedResult, $this->subject->typoLink($linkText, $configuration));
2929 'directImageLink' =>
false,
2930 'parameter' =>
'fileadmin/foo.bar',
2933 '<a href="/fileadmin/foo.bar">My file</a>',
2935 'Link to file with longer absRefPrefix' => [
2938 'directImageLink' =>
false,
2939 'parameter' =>
'fileadmin/foo.bar',
2942 '<a href="/sub/fileadmin/foo.bar">My file</a>',
2944 'Link to absolute file' => [
2947 'directImageLink' =>
false,
2948 'parameter' =>
'/images/foo.bar',
2951 '<a href="/images/foo.bar">My file</a>',
2953 'Link to absolute file with longer absRefPrefix' => [
2956 'directImageLink' =>
false,
2957 'parameter' =>
'/images/foo.bar',
2960 '<a href="/images/foo.bar">My file</a>',
2962 'Link to absolute file with identical longer absRefPrefix' => [
2965 'directImageLink' =>
false,
2966 'parameter' =>
'/sub/fileadmin/foo.bar',
2969 '<a href="/sub/fileadmin/foo.bar">My file</a>',
2971 'Link to file with empty absRefPrefix' => [
2974 'directImageLink' =>
false,
2975 'parameter' =>
'fileadmin/foo.bar',
2978 '<a href="fileadmin/foo.bar">My file</a>',
2980 'Link to absolute file with empty absRefPrefix' => [
2983 'directImageLink' =>
false,
2984 'parameter' =>
'/fileadmin/foo.bar',
2987 '<a href="/fileadmin/foo.bar">My file</a>',
2989 'Link to file with attributes with absRefPrefix' => [
2992 'parameter' =>
'fileadmin/foo.bar',
2993 'ATagParams' =>
'class="file-class"',
2994 'fileTarget' =>
'_blank',
2995 'title' =>
'Title of the file',
2998 '<a href="/fileadmin/foo.bar" title="Title of the file" target="_blank" class="file-class">My file</a>',
3000 'Link to file with attributes with longer absRefPrefix' => [
3003 'parameter' =>
'fileadmin/foo.bar',
3004 'ATagParams' =>
'class="file-class"',
3005 'fileTarget' =>
'_blank',
3006 'title' =>
'Title of the file',
3009 '<a href="/sub/fileadmin/foo.bar" title="Title of the file" target="_blank" class="file-class">My file</a>',
3011 'Link to absolute file with attributes with absRefPrefix' => [
3014 'parameter' =>
'/images/foo.bar',
3015 'ATagParams' =>
'class="file-class"',
3016 'fileTarget' =>
'_blank',
3017 'title' =>
'Title of the file',
3020 '<a href="/images/foo.bar" title="Title of the file" target="_blank" class="file-class">My file</a>',
3022 'Link to absolute file with attributes with longer absRefPrefix' => [
3025 'parameter' =>
'/images/foo.bar',
3026 'ATagParams' =>
'class="file-class"',
3027 'fileTarget' =>
'_blank',
3028 'title' =>
'Title of the file',
3031 '<a href="/images/foo.bar" title="Title of the file" target="_blank" class="file-class">My file</a>',
3033 'Link to absolute file with attributes with identical longer absRefPrefix' => [
3036 'parameter' =>
'/sub/fileadmin/foo.bar',
3037 'ATagParams' =>
'class="file-class"',
3038 'fileTarget' =>
'_blank',
3039 'title' =>
'Title of the file',
3042 '<a href="/sub/fileadmin/foo.bar" title="Title of the file" target="_blank" class="file-class">My file</a>',
3061 $packageManagerMock = $this->getMockBuilder(PackageManager::class)
3062 ->disableOriginalConstructor()
3064 $templateServiceObjectMock = $this->getMockBuilder(TemplateService::class)
3065 ->setConstructorArgs([
null, $packageManagerMock])
3066 ->setMethods([
'dummy'])
3068 $templateServiceObjectMock->setup = [
3073 $resourceFactory = $this->prophesize(ResourceFactory::class);
3074 GeneralUtility::setSingletonInstance(ResourceFactory::class, $resourceFactory->reveal());
3076 $typoScriptFrontendControllerMockObject = $this->createMock(TypoScriptFrontendController::class);
3077 $typoScriptFrontendControllerMockObject->config = [
3080 $typoScriptFrontendControllerMockObject->tmpl = $templateServiceObjectMock;
3081 $GLOBALS[
'TSFE'] = $typoScriptFrontendControllerMockObject;
3082 $GLOBALS[
'TSFE']->absRefPrefix = $absRefPrefix;
3083 $this->subject->_set(
'typoScriptFrontendController', $typoScriptFrontendControllerMockObject);
3085 $this->assertEquals($expectedResult, $this->subject->typoLink($linkText, $configuration));
3093 $linkService = $this->prophesize(LinkService::class);
3094 GeneralUtility::setSingletonInstance(LinkService::class, $linkService->reveal());
3095 $linkService->resolve(
'foo')->willThrow(InvalidPathException::class);
3097 $this->assertSame(
'foo', $this->subject->typoLink(
'foo', [
'parameter' =>
'foo']));
3105 $linkService = $this->prophesize(LinkService::class);
3106 GeneralUtility::setSingletonInstance(LinkService::class, $linkService->reveal());
3107 $linkService->resolve(
'foo')->willThrow(InvalidPathException::class);
3109 $logger = $this->prophesize(Logger::class);
3110 $logger->warning(
'The link could not be generated', Argument::any())->shouldBeCalled();
3111 $this->subject->setLogger($logger->reveal());
3112 $this->subject->typoLink(
'foo', [
'parameter' =>
'foo']);
3124 $expectedResult = 5;
3125 $amountOfEntries = $this->subject->splitObj(
'1, 2, 3, 4, 5', $conf);
3139 $value = $this->getUniqueId(
'value');
3140 $wrap = [$this->getUniqueId(
'wrap')];
3141 $valueConf = [
'key' => $value];
3142 $wrapConf = [
'key.' => $wrap];
3143 $conf = array_merge($valueConf, $wrapConf);
3144 $will = $this->getUniqueId(
'stdWrap');
3155 'value conf only' => [
3163 'wrap conf only' => [
3197 public function calculateCacheKey(
string $expect, array $conf,
int $times, $with, $withWrap, $will): void
3199 $subject = $this->getAccessibleMock(ContentObjectRenderer::class, [
'stdWrap']);
3200 $subject->expects($this->exactly($times))
3202 ->with($with, $withWrap)
3203 ->willReturn($will);
3205 $result =
$subject->_call(
'calculateCacheKey', $conf);
3206 $this->assertSame($expect, $result);
3216 $conf = [$this->getUniqueId(
'conf')];
3218 'empty cache key' => [
3225 'non-empty cache key' => [
3251 public function getFromCache($expect, $conf, $cacheKey, $times, $cached): void
3254 ContentObjectRenderer::class,
3255 [
'calculateCacheKey']
3258 ->expects($this->exactly(1))
3259 ->method(
'calculateCacheKey')
3261 ->willReturn($cacheKey);
3262 $cacheFrontend = $this->createMock(CacheFrontendInterface::class);
3264 ->expects($this->exactly($times))
3267 ->willReturn($cached);
3268 $cacheManager = $this->createMock(CacheManager::class);
3270 ->method(
'getCache')
3271 ->willReturn($cacheFrontend);
3272 GeneralUtility::setSingletonInstance(
3273 CacheManager::class,
3276 $this->assertSame($expect,
$subject->_call(
'getFromCache', $conf));
3287 'invalid single key' => [
null,
'invalid'],
3288 'single key of null' => [
null,
'null'],
3289 'single key of empty string' => [
'',
'empty'],
3290 'single key of non-empty string' => [
'string 1',
'string1'],
3291 'single key of boolean false' => [
false,
'false'],
3292 'single key of boolean true' => [
true,
'true'],
3293 'single key of integer 0' => [0,
'zero'],
3294 'single key of integer 1' => [1,
'one'],
3295 'single key to be trimmed' => [
'string 1',
' string1 '],
3297 'split nothing' => [
'',
'//'],
3298 'split one before' => [
'string 1',
'string1//'],
3299 'split one after' => [
'string 1',
'//string1'],
3300 'split two ' => [
'string 1',
'string1//string2'],
3301 'split three ' => [
'string 1',
'string1//string2//string3'],
3302 'split to be trimmed' => [
'string 1',
' string1 // string2 '],
3303 '0 is not empty' => [0,
'// zero'],
3304 '1 is not empty' => [1,
'// one'],
3305 'true is not empty' => [
true,
'// true'],
3306 'false is empty' => [
'',
'// false'],
3307 'null is empty' => [
'',
'// null'],
3308 'empty string is empty' => [
'',
'// empty'],
3309 'string is not empty' => [
'string 1',
'// string1'],
3310 'first non-empty winns' => [0,
'false//empty//null//zero//one'],
3311 'empty string is fallback' => [
'',
'false // empty // null'],
3356 'string1' =>
'string 1',
3357 'string2' =>
'string 2',
3358 'string3' =>
'string 3',
3366 $this->subject->_set(
'data', $data);
3367 $this->assertSame($expect, $this->subject->getFieldVal(
$fields));
3378 'lower' => [
'x y',
'X Y',
'lower'],
3379 'upper' => [
'X Y',
'x y',
'upper'],
3380 'capitalize' => [
'One Two',
'one two',
'capitalize'],
3381 'ucfirst' => [
'One two',
'one two',
'ucfirst'],
3382 'lcfirst' => [
'oNE TWO',
'ONE TWO',
'lcfirst'],
3383 'uppercamelcase' => [
'CamelCase',
'camel_case',
'uppercamelcase'],
3384 'lowercamelcase' => [
'camelCase',
'camel_case',
'lowercamelcase'],
3397 public function caseshift(
string $expect,
string $content,
string $case): void
3401 $this->subject->caseshift($content, $case)
3412 $case = $this->getUniqueId(
'case');
3425 [[
'', $case], [
'text', $case]],
3428 'multiple nested tags with classes' => [
3429 '<div class="typo3">'
3430 .
'<p>A <b>BOLD<\b> WORD.</p>'
3431 .
'<p>AN <i>ITALIC<\i> WORD.</p>'
3433 '<div class="typo3">'
3434 .
'<p>A <b>bold<\b> word.</p>'
3435 .
'<p>An <i>italic<\i> word.</p>'
3450 [
'',
'',
'A ',
'BOLD',
' WORD.',
'',
'AN ',
'ITALIC',
' WORD.',
'']
3471 public function HTMLcaseshift(
string $expect,
string $content,
string $case, array $with, array $will): void
3473 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
3474 ->setMethods([
'caseshift'])->getMock();
3476 ->expects($this->exactly(count($with)))
3477 ->method(
'caseshift')
3478 ->withConsecutive(...$with)
3479 ->will($this->onConsecutiveCalls(...$will));
3505 $processors = [
'invalidProcessor'];
3506 foreach (array_keys($this->subject->_get(
'stdWrapOrder')) as $key) {
3507 $processors[] = strtr($key, [
'.' =>
'']);
3509 foreach (array_unique($processors) as $processor) {
3511 if (is_callable($method)) {
3517 $this->assertSame(1, $notCallable);
3518 $this->assertSame(86, $callable);
3542 $timeTrackerProphecy = $this->prophesize(TimeTracker::class);
3543 GeneralUtility::setSingletonInstance(TimeTracker::class, $timeTrackerProphecy->reveal());
3546 $expectExceptions = [
'numRows',
'parseFunc',
'split',
'bytes'];
3550 foreach (array_keys($this->subject->_get(
'stdWrapOrder')) as $key) {
3551 $processors[] = strtr($key, [
'.' =>
'']);
3553 foreach (array_unique($processors) as $processor) {
3556 $conf = [$processor =>
'', $processor .
'.' => [
'table' =>
'tt_content']];
3557 $method =
'stdWrap_' . $processor;
3558 $this->subject->$method(
'', $conf);
3559 }
catch (\Exception $e) {
3560 $exceptions[] = $processor;
3563 $this->assertSame($expectExceptions, $exceptions);
3564 $this->assertSame(86, $count);
3584 'stdWrap_stdWrapPreProcess',
3588 'stdWrap_stdWrapOverride',
3592 'stdWrap_stdWrapProcess',
3596 'stdWrap_stdWrapPostProcess',
3597 'stdWrapPostProcess'
3618 string $stdWrapMethod,
3619 string $hookObjectCall
3621 $conf = [$this->getUniqueId(
'conf')];
3622 $content = $this->getUniqueId(
'content');
3623 $processed1 = $this->getUniqueId(
'processed1');
3624 $processed2 = $this->getUniqueId(
'processed2');
3625 $hookObject1 = $this->createMock(
3626 ContentObjectStdWrapHookInterface::class
3628 $hookObject1->expects($this->once())
3629 ->method($hookObjectCall)
3630 ->with($content, $conf)
3631 ->willReturn($processed1);
3632 $hookObject2 = $this->createMock(
3633 ContentObjectStdWrapHookInterface::class
3635 $hookObject2->expects($this->once())
3636 ->method($hookObjectCall)
3637 ->with($processed1, $conf)
3638 ->willReturn($processed2);
3639 $this->subject->_set(
3640 'stdWrapHookObjects',
3641 [$hookObject1, $hookObject2]
3643 $result = $this->subject->$stdWrapMethod($content, $conf);
3644 $this->assertSame($processed2, $result);
3654 $content = $this->getUniqueId(
'content');
3655 $parsed = $this->getUniqueId(
'parsed');
3667 [
'HTMLparser.' => 1],
3674 [
'HTMLparser.' => []],
3678 'non-empty array' => [
3681 [
'HTMLparser.' => [
true]],
3717 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
3718 ->setMethods([
'HTMLparser_TSbridge'])->getMock();
3720 ->expects($this->exactly($times))
3721 ->method(
'HTMLparser_TSbridge')
3722 ->with($content, $conf[
'HTMLparser.'] ?? [])
3723 ->willReturn($will);
3738 [
'addPageCacheTags' =>
''],
3740 'Two expectedTags' => [
3742 [
'addPageCacheTags' =>
'tag1,tag2'],
3744 'Two expectedTags plus one with stdWrap' => [
3745 [
'tag1',
'tag2',
'tag3'],
3747 'addPageCacheTags' =>
'tag1,tag2',
3748 'addPageCacheTags.' => [
'wrap' =>
'|,tag3']
3762 $this->subject->stdWrap_addPageCacheTags(
'', $configuration);
3763 $this->assertEquals($expectedTags, $this->frontendControllerMock->_get(
'pageCacheTags'));
3782 $conf = [
'age' => $this->getUniqueId(
'age')];
3783 $return = $this->getUniqueId(
'return');
3784 $difference = $now - (int)$content;
3786 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
3787 ->setMethods([
'calcAge'])->getMock();
3789 ->expects($this->once())
3791 ->with($difference, $conf[
'age'])
3792 ->willReturn($return);
3811 $debugKey =
'/stdWrap/.append';
3812 $content = $this->getUniqueId(
'content');
3814 'append' => $this->getUniqueId(
'append'),
3815 'append.' => [$this->getUniqueId(
'append.')],
3817 $return = $this->getUniqueId(
'return');
3818 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
3819 ->setMethods([
'cObjGetSingle'])->getMock();
3821 ->expects($this->once())
3822 ->method(
'cObjGetSingle')
3823 ->with($conf[
'append'], $conf[
'append.'], $debugKey)
3824 ->willReturn($return);
3839 'no xhtml with LF in between' => [
3840 'one<br>' . LF .
'two',
3844 'no xhtml with LF in between and around' => [
3845 '<br>' . LF .
'one<br>' . LF .
'two<br>' . LF,
3846 LF .
'one' . LF .
'two' . LF,
3849 'xhtml with LF in between' => [
3850 'one<br />' . LF .
'two',
3854 'xhtml with LF in between and around' => [
3855 '<br />' . LF .
'one<br />' . LF .
'two<br />' . LF,
3856 LF .
'one' . LF .
'two' . LF,
3871 public function stdWrap_br($expected, $input, $xhtmlDoctype): void
3873 $GLOBALS[
'TSFE']->xhtmlDoctype = $xhtmlDoctype;
3874 $this->assertSame($expected, $this->subject->stdWrap_br($input));
3885 $config1 = [
'brTag' =>
'<br/>'];
3886 $config2 = [
'brTag' =>
'<br>'];
3888 'no config: one break at the beginning' => [LF .
'one' . LF .
'two',
'onetwo', $noConfig],
3889 'no config: multiple breaks at the beginning' => [LF . LF .
'one' . LF .
'two',
'onetwo', $noConfig],
3890 'no config: one break at the end' => [
'one' . LF .
'two' . LF,
'onetwo', $noConfig],
3891 'no config: multiple breaks at the end' => [
'one' . LF .
'two' . LF . LF,
'onetwo', $noConfig],
3893 'config1: one break at the beginning' => [LF .
'one' . LF .
'two',
'<br/>one<br/>two', $config1],
3894 'config1: multiple breaks at the beginning' => [
3895 LF . LF .
'one' . LF .
'two',
3896 '<br/><br/>one<br/>two',
3899 'config1: one break at the end' => [
'one' . LF .
'two' . LF,
'one<br/>two<br/>', $config1],
3900 'config1: multiple breaks at the end' => [
'one' . LF .
'two' . LF . LF,
'one<br/>two<br/><br/>', $config1],
3902 'config2: one break at the beginning' => [LF .
'one' . LF .
'two',
'<br>one<br>two', $config2],
3903 'config2: multiple breaks at the beginning' => [
3904 LF . LF .
'one' . LF .
'two',
3905 '<br><br>one<br>two',
3908 'config2: one break at the end' => [
'one' . LF .
'two' . LF,
'one<br>two<br>', $config2],
3909 'config2: multiple breaks at the end' => [
'one' . LF .
'two' . LF . LF,
'one<br>two<br><br>', $config2],
3922 public function stdWrap_brTag(
string $input,
string $expected, array $config): void
3924 $this->assertEquals($expected, $this->subject->stdWrap_brTag($input, $config));
3935 'value 1234 default' => [
3938 [
'labels' =>
'',
'base' => 0],
3940 'value 1234 si' => [
3943 [
'labels' =>
'si',
'base' => 0],
3945 'value 1234 iec' => [
3948 [
'labels' =>
'iec',
'base' => 0],
3950 'value 1234 a-i' => [
3953 [
'labels' =>
'a|b|c|d|e|f|g|h|i',
'base' => 1000],
3955 'value 1234 a-i invalid base' => [
3958 [
'labels' =>
'a|b|c|d|e|f|g|h|i',
'base' => 54],
3960 'value 1234567890 default' => [
3963 [
'labels' =>
'',
'base' => 0],
3989 public function stdWrap_bytes(
string $expect,
string $content, array $conf): void
3991 $locale =
'en_US.UTF-8';
3993 $this->setLocale(LC_NUMERIC, $locale);
3995 $this->markTestSkipped(
'Locale ' . $locale .
' is not available.');
3997 $conf = [
'bytes.' => $conf];
4000 $this->subject->stdWrap_bytes($content, $conf)
4019 $debugKey =
'/stdWrap/.cObject';
4020 $content = $this->getUniqueId(
'content');
4022 'cObject' => $this->getUniqueId(
'cObject'),
4023 'cObject.' => [$this->getUniqueId(
'cObject.')],
4025 $return = $this->getUniqueId(
'return');
4026 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
4027 ->setMethods([
'cObjGetSingle'])->getMock();
4029 ->expects($this->once())
4030 ->method(
'cObjGetSingle')
4031 ->with($conf[
'cObject'], $conf[
'cObject.'], $debugKey)
4032 ->willReturn($return);
4046 $confA = [$this->getUniqueId(
'conf A')];
4047 $confB = [$this->getUniqueId(
'conf B')];
4049 'standard case: order 1, 2' => [
4052 [
'1.' => $confA,
'2.' => $confB]
4054 'inverted: order 2, 1' => [
4057 [
'2.' => $confA,
'1.' => $confB]
4059 '0 as integer: order 0, 2' => [
4062 [
'0.' => $confA,
'2.' => $confB]
4064 'negative integers: order 2, -2' => [
4067 [
'2.' => $confA,
'-2.' => $confB]
4069 'chars are casted to key 0, that is not in the array' => [
4072 [
'2.' => $confB,
'xxx.' => $confA]
4101 $content = $this->getUniqueId(
'content');
4102 $between = $this->getUniqueId(
'between');
4103 $expect = $this->getUniqueId(
'expect');
4104 $conf[
'orderedStdWrap.'] = $conf;
4105 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
4106 ->setMethods([
'stdWrap'])->getMock();
4108 ->expects($this->exactly(2))
4110 ->withConsecutive([$content, $firstConf], [$between, $secondConf])
4111 ->will($this->onConsecutiveCalls($between, $expect));
4125 $cacheConf = [$this->getUniqueId(
'cache.')];
4126 $conf = [
'cache.' => $cacheConf];
4136 'no cache. conf' => [
4144 'non-cached simulation' => [
4152 'cached simulation' => [
4188 ContentObjectRenderer::class,
4192 ->expects($this->exactly($times))
4193 ->method(
'getFromCache')
4195 ->willReturn($will);
4209 $confCache = [$this->getUniqueId(
'cache.')];
4210 $key = [$this->getUniqueId(
'key')];
4212 'Return immediate with no conf' => [
4218 'Return immediate with empty key' => [
4224 'Call all methods' => [
4260 $content = $this->getUniqueId(
'content');
4261 $conf[
'cache.'] = $confCache;
4262 $tags = [$this->getUniqueId(
'tags')];
4263 $lifetime = $this->getUniqueId(
'lifetime');
4266 'content' => $content,
4267 'lifetime' => $lifetime,
4271 ContentObjectRenderer::class,
4273 'calculateCacheKey',
4274 'calculateCacheTags',
4275 'calculateCacheLifetime'
4279 ->expects($this->exactly($timesCCK))
4280 ->method(
'calculateCacheKey')
4284 ->expects($this->exactly($times))
4285 ->method(
'calculateCacheTags')
4287 ->willReturn($tags);
4289 ->expects($this->exactly($times))
4290 ->method(
'calculateCacheLifetime')
4292 ->willReturn($lifetime);
4293 $cacheFrontend = $this->createMock(CacheFrontendInterface::class);
4295 ->expects($this->exactly($times))
4297 ->with($key, $content, $tags, $lifetime)
4299 $cacheManager = $this->createMock(CacheManager::class);
4301 ->method(
'getCache')
4302 ->willReturn($cacheFrontend);
4303 GeneralUtility::setSingletonInstance(
4304 CacheManager::class,
4307 list($countCalls, $test) = [0, $this];
4308 $closure =
function ($par1, $par2) use (
4314 $test->assertSame($params, $par1);
4318 $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'stdWrap_cacheStore'] = [
4327 $this->assertSame($times * 3, $countCalls);
4344 $content = $this->getUniqueId();
4346 'case' => $this->getUniqueId(
'used'),
4347 'case.' => [$this->getUniqueId(
'discarded')],
4349 $return = $this->getUniqueId();
4350 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
4351 ->setMethods([
'HTMLcaseshift'])->getMock();
4353 ->expects($this->once())
4354 ->method(
'HTMLcaseshift')
4355 ->with($content, $conf[
'case'])
4356 ->willReturn($return);
4370 $input =
'discarded';
4372 $this->assertEquals($expected, $this->subject->stdWrap_char($input, [
'char' =>
'67']));
4389 $content = $this->getUniqueId(
'content');
4391 'crop' => $this->getUniqueId(
'crop'),
4392 'crop.' => $this->getUniqueId(
'not used'),
4394 $return = $this->getUniqueId(
'return');
4395 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
4396 ->setMethods([
'crop'])->getMock();
4398 ->expects($this->once())
4400 ->with($content, $conf[
'crop'])
4401 ->willReturn($return);
4422 $content = $this->getUniqueId(
'content');
4424 'cropHTML' => $this->getUniqueId(
'cropHTML'),
4425 'cropHTML.' => $this->getUniqueId(
'not used'),
4427 $return = $this->getUniqueId(
'return');
4428 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
4429 ->setMethods([
'cropHTML'])->getMock();
4431 ->expects($this->once())
4432 ->method(
'cropHTML')
4433 ->with($content, $conf[
'cropHTML'])
4434 ->willReturn($return);
4449 'empty string from ISO-8859-15' => [
4451 mb_convert_encoding(
'',
'ISO-8859-15',
'UTF-8'),
4452 [
'csConv' =>
'ISO-8859-15']
4454 'empty string from BIG-5' => [
4456 mb_convert_encoding(
'',
'BIG-5'),
4457 [
'csConv' =>
'BIG-5']
4459 '"0" from ISO-8859-15' => [
4461 mb_convert_encoding(
'0',
'ISO-8859-15',
'UTF-8'),
4462 [
'csConv' =>
'ISO-8859-15']
4464 '"0" from BIG-5' => [
4466 mb_convert_encoding(
'0',
'BIG-5'),
4467 [
'csConv' =>
'BIG-5']
4469 'euro symbol from ISO-88859-15' => [
4471 mb_convert_encoding(
'€',
'ISO-8859-15',
'UTF-8'),
4472 [
'csConv' =>
'ISO-8859-15']
4474 'good morning from BIG-5' => [
4476 mb_convert_encoding(
'早安',
'BIG-5'),
4477 [
'csConv' =>
'BIG-5']
4491 public function stdWrap_csConv(
string $expected,
string $input, array $conf): void
4495 $this->subject->stdWrap_csConv($input, $conf)
4513 'currentValue_kidjls9dksoje' =>
'default',
4514 'currentValue_new' =>
'new',
4516 $this->subject->_set(
'data', $data);
4518 'currentValue_kidjls9dksoje',
4519 $this->subject->_get(
'currentValKey')
4523 $this->subject->stdWrap_current(
'discarded', [
'discarded'])
4525 $this->subject->_set(
'currentValKey',
'currentValue_new');
4528 $this->subject->stdWrap_current(
'discarded', [
'discarded'])
4539 $data = [$this->getUniqueId(
'data')];
4540 $alt = [$this->getUniqueId(
'alternativeData')];
4542 'default' => [$data, $data,
''],
4543 'alt is array' => [$alt, $data, $alt],
4544 'alt is empty array' => [[], $data, []],
4545 'alt null' => [$data, $data,
null],
4546 'alt string' => [$data, $data,
'xxx'],
4547 'alt int' => [$data, $data, 1],
4548 'alt bool' => [$data, $data,
true],
4570 public function stdWrap_data(array $expect, array $data, $alt): void
4572 $conf = [
'data' => $this->getUniqueId(
'conf.data')];
4573 $return = $this->getUniqueId(
'return');
4575 ContentObjectRenderer::class,
4579 $subject->_set(
'alternativeData', $alt);
4581 ->expects($this->once())
4583 ->with($conf[
'data'], $expect)
4584 ->willReturn($return);
4586 $this->assertSame(
'',
$subject->_get(
'alternativeData'));
4603 $content = $this->getUniqueId(
'content');
4605 'dataWrap' => $this->getUniqueId(
'dataWrap'),
4606 'dataWrap.' => [$this->getUniqueId(
'not used')],
4608 $return = $this->getUniqueId(
'return');
4609 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
4610 ->setMethods([
'dataWrap'])->getMock();
4612 ->expects($this->once())
4613 ->method(
'dataWrap')
4614 ->with($content, $conf[
'dataWrap'])
4615 ->willReturn($return);
4632 'given timestamp' => [
4635 [
'date' =>
'd.m.Y'],
4641 [
'date' =>
'd.m.Y'],
4647 [
'date' =>
'd.m.Y'],
4650 'given timestamp return GMT' => [
4651 '02.10.2015 10:00:00',
4654 'date' =>
'd.m.Y H:i:s',
4655 'date.' => [
'GMT' =>
true],
4672 public function stdWrap_date(
string $expected, $content, array $conf,
int $now): void
4675 $this->assertEquals(
4677 $this->subject->stdWrap_date($content, $conf)
4688 $expect =
'<pre><p class="class"><br/>'
4689 .
'</p></pre>';
4690 $content =
'<p class="class"><br/></p>';
4691 $this->assertSame($expect, $this->subject->stdWrap_debug($content));
4722 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'devIPmask'] =
'*';
4723 $content = $this->getUniqueId(
'content');
4724 $key = $this->getUniqueId(
'key');
4725 $value = $this->getUniqueId(
'value');
4726 $altValue = $this->getUniqueId(
'value alt');
4727 $this->subject->data = [$key => $value];
4730 $result = $this->subject->stdWrap_debugData($content);
4731 $out = ob_get_clean();
4732 $this->assertSame($result, $content);
4733 $this->assertContains(
'$cObj->data', $out);
4734 $this->assertContains($value, $out);
4735 $this->assertNotContains($altValue, $out);
4737 $this->subject->alternativeData = [$key => $altValue];
4739 $this->subject->stdWrap_debugData($content);
4740 $out = ob_get_clean();
4741 $this->assertNotContains(
'$cObj->alternativeData', $out);
4742 $this->assertContains($value, $out);
4743 $this->assertContains($altValue, $out);
4754 'expect array by string' => [
true,
'2'],
4755 'expect array by integer' => [
true, 2],
4756 'do not expect array' => [
false,
''],
4783 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'devIPmask'] =
'*';
4784 $content = $this->getUniqueId(
'content');
4785 $conf = [
'debugFunc' => $confDebugFunc];
4787 $result = $this->subject->stdWrap_debugFunc($content, $conf);
4788 $out = ob_get_clean();
4789 $this->assertSame($result, $content);
4790 $this->assertContains($content, $out);
4792 $this->assertContains(
'=>', $out);
4794 $this->assertNotContains(
'=>', $out);
4806 'no config: void input' => [
4811 'no config: single break' => [
4816 'no config: double break' => [
4818 'one' . LF . LF .
'two',
4821 'no config: double break with whitespace' => [
4823 'one' . LF .
"\t" .
' ' .
"\t" .
' ' . LF .
'two',
4826 'no config: single break around' => [
4831 'no config: double break around' => [
4833 LF . LF .
'one' . LF . LF,
4836 'empty string: double break around' => [
4838 LF . LF .
'one' . LF . LF,
4839 [
'doubleBrTag' =>
''],
4841 'br tag: double break' => [
4843 'one' . LF . LF .
'two',
4844 [
'doubleBrTag' =>
'<br/>'],
4846 'br tag: double break around' => [
4848 LF . LF .
'one' . LF . LF,
4849 [
'doubleBrTag' =>
'<br/>'],
4851 'double br tag: double break around' => [
4852 '<br/><br/>one<br/><br/>',
4853 LF . LF .
'one' . LF . LF,
4854 [
'doubleBrTag' =>
'<br/><br/>'],
4870 $this->assertEquals($expected, $this->subject->stdWrap_doubleBrTag($input, $config));
4880 $content = $this->getUniqueId(
'content');
4881 $editIcons = $this->getUniqueId(
'editIcons');
4882 $editIconsArray = [$this->getUniqueId(
'editIcons.')];
4883 $will = $this->getUniqueId(
'will');
4885 'standard case calls edit icons' => [
4888 [
'editIcons' => $editIcons,
'editIcons.' => $editIconsArray],
4894 'null in editIcons. repalaced by []' => [
4897 [
'editIcons' => $editIcons,
'editIcons.' =>
null],
4903 'missing editIcons. replaced by []' => [
4906 [
'editIcons' => $editIcons],
4912 'no user login disables call' => [
4915 [
'editIcons' => $editIcons,
'editIcons.' => $editIconsArray],
4921 'empty string in editIcons disables call' => [
4924 [
'editIcons' =>
'',
'editIcons.' => $editIconsArray],
4930 'zero string in editIcons disables call' => [
4933 [
'editIcons' =>
'0',
'editIcons.' => $editIconsArray],
4979 $backendUser->user[
'uid'] = 13;
4980 GeneralUtility::makeInstance(Context::class)->setAspect(
'backend.user',
new UserAspect($backendUser));
4982 GeneralUtility::makeInstance(Context::class)->setAspect(
'backend.user',
new UserAspect());
4984 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
4985 ->setMethods([
'editIcons'])->getMock();
4987 ->expects($this->exactly($times))
4988 ->method(
'editIcons')
4989 ->with($content, $conf[
'editIcons'], $param3)
4990 ->willReturn($will);
5011 $content = $this->getUniqueId(
'content');
5013 'encapsLines' => [$this->getUniqueId(
'not used')],
5014 'encapsLines.' => [$this->getUniqueId(
'encapsLines.')],
5016 $return = $this->getUniqueId(
'return');
5017 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
5018 ->setMethods([
'encaps_lineSplit'])->getMock();
5020 ->expects($this->once())
5021 ->method(
'encaps_lineSplit')
5022 ->with($content, $conf[
'encapsLines.'])
5023 ->willReturn($return);
5045 'encapsLines' => $rteParseFunc[
'parseFunc.'][
'nonTypoTagStdWrap.'][
'encapsLines'] ??
null,
5046 'encapsLines.' => $rteParseFunc[
'parseFunc.'][
'nonTypoTagStdWrap.'][
'encapsLines.'] ??
null,
5049 $conf[
'encapsLines.'][
'innerStdWrap_all.'][
'ifBlank'] =
'';
5050 $additionalEncapsTags = [
'a',
'b',
'span'];
5054 $conf[
'encapsLines.'][
'encapsTagList'] .=
',' . implode(
',', $additionalEncapsTags);
5055 $conf[
'encapsLines.'][
'encapsTagList'] .=
',' . implode(
',', [$input]);
5059 $content =
'<' . $input .
' id="myId" class="bodytext" />';
5060 $result = $this->subject->stdWrap_encapsLines($content, $conf);
5061 $this->assertSame($expected, $result);
5070 'areaTag_selfclosing' => [
5072 'expected' =>
'<area id="myId" class="bodytext" />'
5074 'base_selfclosing' => [
5076 'expected' =>
'<base id="myId" class="bodytext" />'
5078 'br_selfclosing' => [
5080 'expected' =>
'<br id="myId" class="bodytext" />'
5082 'col_selfclosing' => [
5084 'expected' =>
'<col id="myId" class="bodytext" />'
5086 'embed_selfclosing' => [
5088 'expected' =>
'<embed id="myId" class="bodytext" />'
5090 'hr_selfclosing' => [
5092 'expected' =>
'<hr id="myId" class="bodytext" />'
5094 'img_selfclosing' => [
5096 'expected' =>
'<img id="myId" class="bodytext" />'
5098 'input_selfclosing' => [
5100 'expected' =>
'<input id="myId" class="bodytext" />'
5102 'keygen_selfclosing' => [
5103 'input' =>
'keygen',
5104 'expected' =>
'<keygen id="myId" class="bodytext" />'
5106 'link_selfclosing' => [
5108 'expected' =>
'<link id="myId" class="bodytext" />'
5110 'meta_selfclosing' => [
5112 'expected' =>
'<meta id="myId" class="bodytext" />'
5114 'param_selfclosing' => [
5116 'expected' =>
'<param id="myId" class="bodytext" />'
5118 'source_selfclosing' => [
5119 'input' =>
'source',
5120 'expected' =>
'<source id="myId" class="bodytext" />'
5122 'track_selfclosing' => [
5124 'expected' =>
'<track id="myId" class="bodytext" />'
5126 'wbr_selfclosing' => [
5128 'expected' =>
'<wbr id="myId" class="bodytext" />'
5130 'p_notselfclosing' => [
5132 'expected' =>
'<p id="myId" class="bodytext"></p>'
5134 'a_notselfclosing' => [
5136 'expected' =>
'<a id="myId" class="bodytext"></a>'
5138 'strong_notselfclosing' => [
5139 'input' =>
'strong',
5140 'expected' =>
'<strong id="myId" class="bodytext"></strong>'
5142 'span_notselfclosing' => [
5144 'expected' =>
'<span id="myId" class="bodytext"></span>'
5156 $content = $this->getUniqueId(
'content');
5157 $will = $this->getUniqueId(
'will');
5159 'standard case calls edit icons' => [
5166 'no user login disables call' => [
5206 $backendUser->user[
'uid'] = 13;
5207 GeneralUtility::makeInstance(Context::class)->setAspect(
'backend.user',
new UserAspect($backendUser));
5209 GeneralUtility::makeInstance(Context::class)->setAspect(
'backend.user',
new UserAspect());
5211 $conf = [
'editPanel.' => [$this->getUniqueId(
'editPanel.')]];
5212 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
5213 ->setMethods([
'editPanel'])->getMock();
5215 ->expects($this->exactly($times))
5216 ->method(
'editPanel')
5217 ->with($content, $conf[
'editPanel.'])
5218 ->willReturn($will);
5233 'double quote in string' => [
5234 '\'double\u0020quote\u0022\
'',
5237 'backslash in string' => [
5238 '\'backslash\u0020\u005C\
'',
5241 'exclamation mark' => [
5242 '\'exclamation\u0021\
'',
5245 'whitespace tab, newline and carriage return' => [
5246 '\'white\u0009space\u000As\u000D\
'',
5249 'single quote in string' => [
5250 '\'single\u0020quote\u0020\u0027\
'',
5254 '\'\u003Ctag\u003E\
'',
5257 'ampersand in string' => [
5258 '\'amper\u0026sand\
'',
5276 $this->subject->stdWrap_encodeForJavaScriptValue($content)
5288 'numbers' => [
'1,2,3',
'1,2,3'],
5289 'range' => [
'3,4,5',
'3-5'],
5290 'numbers and range' => [
'1,3,4,5,7',
'1,3-5,7']
5309 $this->assertEquals(
5311 $this->subject->stdWrap_expandList($content)
5327 $expect = $this->getUniqueId(
'expect');
5328 $conf = [
'field' => $this->getUniqueId(
'field')];
5329 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
5330 ->setMethods([
'getFieldVal'])->getMock();
5332 ->expects($this->once())
5333 ->method(
'getFieldVal')
5334 ->with($conf[
'field'])
5335 ->willReturn($expect);
5349 $content = $this->getUniqueId(
'content');
5352 'false is false' => [
5356 [
'fieldRequired' =>
'false']
5358 'null is false' => [
5362 [
'fieldRequired' =>
'null']
5364 'empty string is false' => [
5368 [
'fieldRequired' =>
'empty']
5370 'whitespace is false' => [
5374 [
'fieldRequired' =>
'whitespace']
5376 'string zero is false' => [
5380 [
'fieldRequired' =>
'stringZero']
5382 'string zero with whitespace is false' => [
5386 [
'fieldRequired' =>
'stringZeroWithWhiteSpace']
5388 'zero is false' => [
5392 [
'fieldRequired' =>
'zero']
5399 [
'fieldRequired' =>
'true']
5401 'string is true' => [
5405 [
'fieldRequired' =>
'string']
5411 [
'fieldRequired' =>
'one']
5441 'whitespace' =>
"\t" .
' ',
5442 'stringZero' =>
'0',
5443 'stringZeroWithWhiteSpace' =>
"\t" .
' 0 ' .
"\t",
5445 'string' =>
'string',
5451 $subject->_set(
'stdWrapRecursionLevel', 1);
5452 $subject->_set(
'stopRendering', [1 =>
false]);
5457 $this->assertSame($stop,
$subject->_get(
'stopRendering')[1]);
5469 'bacb98acf97e0b6112b1d1b650b84971',
5474 '063b3d108bed9f88fa618c6046de0dccadcf3158',
5478 'stdWrap capability' => [
5479 'bacb98acf97e0b6112b1d1b650b84971',
5483 'hash.' => [
'wrap' =>
'md|']
5486 'non-existing hashing algorithm' => [
5489 [
'hash' =>
'non-existing']
5509 public function stdWrap_hash(
string $expect,
string $content, array $conf): void
5513 $this->subject->stdWrap_hash($content, $conf)
5526 '<span>1 &lt; 2</span>',
5527 '<span>1 < 2</span>',
5530 'void preserveEntities' => [
5531 '<span>1 &lt; 2</span>',
5532 '<span>1 < 2</span>',
5533 [
'htmlSpecialChars.' => []],
5535 'false preserveEntities' => [
5536 '<span>1 &lt; 2</span>',
5537 '<span>1 < 2</span>',
5538 [
'htmlSpecialChars.' => [
'preserveEntities' => 0]],
5540 'true preserveEntities' => [
5541 '<span>1 < 2</span>',
5542 '<span>1 < 2</span>',
5543 [
'htmlSpecialChars.' => [
'preserveEntities' => 1]],
5561 $this->subject->stdWrap_htmlSpecialChars($input, $conf)
5572 $content = $this->getUniqueId(
'content');
5573 $conf = [
'if.' => [$this->getUniqueId(
'if.')]];
5584 'if. is empty array' => [
5624 'checkIf returning true' => [
5633 'checkIf returning false' => [
5664 public function stdWrap_if(
string $expect,
bool $stop,
string $content, array $conf,
int $times, $will): void
5667 ContentObjectRenderer::class,
5670 $subject->_set(
'stdWrapRecursionLevel', 1);
5671 $subject->_set(
'stopRendering', [1 =>
false]);
5673 ->expects($this->exactly($times))
5675 ->with($conf[
'if.'] ??
null)
5676 ->willReturn($will);
5678 $this->assertSame($stop,
$subject->_get(
'stopRendering')[1]);
5688 $alt = $this->getUniqueId(
'alternative content');
5689 $conf = [
'ifBlank' => $alt];
5692 'null is blank' => [$alt,
null, $conf],
5693 'false is blank' => [$alt,
false, $conf],
5694 'empty string is blank' => [$alt,
'', $conf],
5695 'whitespace is blank' => [$alt,
"\t" .
'', $conf],
5697 'string is not blank' => [
'string',
'string', $conf],
5698 'zero is not blank' => [0, 0, $conf],
5699 'zero string is not blank' => [
'0',
'0', $conf],
5700 'zero float is not blank' => [0.0, 0.0, $conf],
5701 'true is not blank' => [
true,
true, $conf],
5723 $result = $this->subject->stdWrap_ifBlank($content, $conf);
5724 $this->assertSame($expect, $result);
5734 $alt = $this->getUniqueId(
'alternative content');
5735 $conf = [
'ifEmpty' => $alt];
5738 'null is empty' => [$alt,
null, $conf],
5739 'false is empty' => [$alt,
false, $conf],
5740 'zero is empty' => [$alt, 0, $conf],
5741 'float zero is empty' => [$alt, 0.0, $conf],
5742 'whitespace is empty' => [$alt,
"\t" .
' ', $conf],
5743 'empty string is empty' => [$alt,
'', $conf],
5744 'zero string is empty' => [$alt,
'0', $conf],
5745 'zero string is empty with whitespace' => [
5747 "\t" .
' 0 ' .
"\t",
5751 'string is not empty' => [
'string',
'string', $conf],
5752 '1 is not empty' => [1, 1, $conf],
5753 '-1 is not empty' => [-1, -1, $conf],
5754 '0.1 is not empty' => [0.1, 0.1, $conf],
5755 '-0.1 is not empty' => [-0.1, -0.1, $conf],
5756 'true is not empty' => [
true,
true, $conf],
5777 $result = $this->subject->stdWrap_ifEmpty($content, $conf);
5778 $this->assertSame($expect, $result);
5788 $alt = $this->getUniqueId(
'alternative content');
5789 $conf = [
'ifNull' => $alt];
5791 'only null is null' => [$alt,
null, $conf],
5792 'zero is not null' => [0, 0, $conf],
5793 'float zero is not null' => [0.0, 0.0, $conf],
5794 'false is not null' => [
false,
false, $conf],
5795 'zero is not null' => [0, 0, $conf],
5796 'zero string is not null' => [
'0',
'0', $conf],
5797 'empty string is not null' => [
'',
'', $conf],
5798 'whitespace is not null' => [
"\t" .
'',
"\t" .
'', $conf],
5819 $result = $this->subject->stdWrap_ifNull($content, $conf);
5820 $this->assertSame($expect, $result);
5839 [
'innerWrap' =>
'<wrap>|</wrap>'],
5841 'missing pipe puts wrap before' => [
5844 [
'innerWrap' =>
'<pre>'],
5846 'trims whitespace' => [
5849 [
'innerWrap' =>
'<wrap>' .
"\t" .
' | ' .
"\t" .
'</wrap>'],
5851 'split char change is not possible' => [
5852 '<wrap> # </wrap>XXX',
5855 'innerWrap' =>
'<wrap> # </wrap>',
5856 'innerWrap.' => [
'splitChar' =>
'#'],
5871 public function stdWrap_innerWrap(
string $expected,
string $input, array $conf): void
5875 $this->subject->stdWrap_innerWrap($input, $conf)
5895 [
'innerWrap2' =>
'<wrap>|</wrap>'],
5897 'missing pipe puts wrap before' => [
5900 [
'innerWrap2' =>
'<pre>'],
5902 'trims whitespace' => [
5905 [
'innerWrap2' =>
'<wrap>' .
"\t" .
' | ' .
"\t" .
'</wrap>'],
5907 'split char change is not possible' => [
5908 '<wrap> # </wrap>XXX',
5911 'innerWrap2' =>
'<wrap> # </wrap>',
5912 'innerWrap2.' => [
'splitChar' =>
'#'],
5931 $this->subject->stdWrap_innerWrap2($input, $conf)
5948 $content = $this->getUniqueId(
'content');
5949 $conf = [$this->getUniqueId(
'conf not used')];
5950 $return = $this->getUniqueId(
'return');
5951 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
5952 ->setMethods([
'insertData'])->getMock();
5953 $subject->expects($this->once())->method(
'insertData')
5954 ->with($content)->willReturn($return);
5969 'empty' => [
'',
''],
5970 'notFoundData' => [
'any=1',
'any{$string}=1'],
5971 'queryParameter' => [
'any{#string}=1',
'any{#string}=1'],
5985 $this->assertSame($expect, $this->subject->stdWrap_insertData($content));
5997 'int' => [123, 123],
5998 'float' => [123, 123.45],
5999 'float does not round up' => [123, 123.55],
6001 'negative int' => [-123, -123],
6002 'negative float' => [-123, -123.45],
6003 'negative float does not round down' => [-123, -123.55],
6005 'word string' => [0,
'string'],
6006 'empty string' => [0,
''],
6007 'zero string' => [0,
'0'],
6008 'int string' => [123,
'123'],
6009 'float string' => [123,
'123.55'],
6010 'negative float string' => [-123,
'-123.55'],
6012 'null' => [0,
null],
6013 'true' => [1,
true],
6014 'false' => [0,
false]
6039 $this->assertSame($expect, $this->subject->stdWrap_intval($content));
6050 'empty string' => [
'',
''],
6051 'blank' => [
'',
' '],
6052 'tab' => [
'',
"\t"],
6053 'single semicolon' => [
',',
' ; '],
6054 'single comma' => [
',',
' , '],
6055 'single nl' => [
',',
' ' . PHP_EOL .
' '],
6056 'double semicolon' => [
',,',
' ; ; '],
6057 'double comma' => [
',,',
' , , '],
6058 'double nl' => [
',,',
' ' . PHP_EOL .
' ' . PHP_EOL .
' '],
6059 'simple word' => [
'one',
' one '],
6060 'simple word trimmed' => [
'one',
'one'],
6061 ', separated' => [
'one,two',
' one , two '],
6062 '; separated' => [
'one,two',
' one ; two '],
6063 'nl separated' => [
'one,two',
' one ' . PHP_EOL .
' two '],
6064 ', typical' => [
'one,two,three',
'one, two, three'],
6065 '; typical' => [
'one,two,three',
' one; two; three'],
6068 'one' . PHP_EOL .
'two' . PHP_EOL .
'three'
6070 ', sourounded' => [
',one,two,',
' , one , two , '],
6071 '; sourounded' => [
',one,two,',
' ; one ; two ; '],
6072 'nl sourounded' => [
6074 ' ' . PHP_EOL .
' one ' . PHP_EOL .
' two ' . PHP_EOL .
' '
6077 'one,two,three,four',
6078 ' one, two; three' . PHP_EOL .
'four'
6080 'keywods with blanks in words' => [
6081 'one plus,two minus',
6082 ' one plus , two minus ',
6097 $this->assertSame($expected, $this->subject->stdWrap_keywords($input));
6114 'translation de' => [
6119 'de' =>
'Übersetzung',
6120 'it' =>
'traduzione',
6125 'translation it' => [
6130 'de' =>
'Übersetzung',
6131 'it' =>
'traduzione',
6136 'no translation' => [
6141 'de' =>
'Übersetzung',
6142 'it' =>
'traduzione',
6147 'missing label' => [
6152 'de' =>
'Übersetzung',
6153 'it' =>
'traduzione',
6171 public function stdWrap_langViaTSFE(
string $expected,
string $input, array $conf,
string $language): void
6174 $this->frontendControllerMock
6175 ->config[
'config'][
'language'] = $language;
6179 $this->subject->stdWrap_lang($input, $conf)
6199 'locale' =>
'en_UK',
6200 'typo3Language' => $language,
6202 $request =
new ServerRequest();
6203 $GLOBALS[
'TYPO3_REQUEST'] = $request->withAttribute(
6205 $site->getLanguageById(2)
6210 $this->subject->stdWrap_lang($input, $conf)
6229 $content = $this->getUniqueId(
'content');
6231 'listNum' => $this->getUniqueId(
'listNum'),
6233 'splitChar' => $this->getUniqueId(
'splitChar')
6236 $return = $this->getUniqueId(
'return');
6237 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
6238 ->setMethods([
'listNum'])->getMock();
6240 ->expects($this->once())
6245 $conf[
'listNum.'][
'splitChar']
6247 ->willReturn($return);
6262 'Standard case' => [
6263 ' left middle right ',
6266 'noTrimWrap' =>
'| left | right |',
6269 'Tabs as whitespace' => [
6270 "\t" .
'left' .
"\t" .
'middle' .
"\t" .
'right' .
"\t",
6274 '|' .
"\t" .
'left' .
"\t" .
'|' .
"\t" .
'right' .
"\t" .
'|',
6277 'Split char is 0' => [
6278 ' left middle right ',
6281 'noTrimWrap' =>
'0 left 0 right 0',
6282 'noTrimWrap.' => [
'splitChar' =>
'0'],
6285 'Split char is pipe (default)' => [
6286 ' left middle right ',
6289 'noTrimWrap' =>
'| left | right |',
6290 'noTrimWrap.' => [
'splitChar' =>
'|'],
6293 'Split char is a' => [
6294 ' left middle right ',
6297 'noTrimWrap' =>
'a left a right a',
6298 'noTrimWrap.' => [
'splitChar' =>
'a'],
6301 'Split char is a word (ab)' => [
6302 ' left middle right ',
6305 'noTrimWrap' =>
'ab left ab right ab',
6306 'noTrimWrap.' => [
'splitChar' =>
'ab'],
6309 'Split char accepts stdWrap' => [
6310 ' left middle right ',
6313 'noTrimWrap' =>
'abc left abc right abc',
6316 'splitChar.' => [
'wrap' =>
'a|c'],
6336 $this->subject->stdWrap_noTrimWrap($content, $conf)
6354 'numRows' => $this->getUniqueId(
'numRows'),
6355 'numRows.' => [$this->getUniqueId(
'numRows')],
6357 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
6358 ->setMethods([
'numRows'])->getMock();
6359 $subject->expects($this->once())->method(
'numRows')
6360 ->with($conf[
'numRows.'])->willReturn(
'return');
6381 $content = $this->getUniqueId(
'content');
6383 'numberFormat' => $this->getUniqueId(
'not used'),
6384 'numberFormat.' => [$this->getUniqueId(
'numberFormat.')],
6386 $return = $this->getUniqueId(
'return');
6387 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
6388 ->setMethods([
'numberFormat'])->getMock();
6390 ->expects($this->once())
6391 ->method(
'numberFormat')
6392 ->with($content, $conf[
'numberFormat.'])
6393 ->willReturn($return);
6416 [
'outerWrap' =>
'<wrap>|</wrap>'],
6418 'missing pipe puts wrap before' => [
6421 [
'outerWrap' =>
'<pre>'],
6423 'trims whitespace' => [
6426 [
'outerWrap' =>
'<wrap>' .
"\t" .
' | ' .
"\t" .
'</wrap>'],
6428 'split char change is not possible' => [
6429 '<wrap> # </wrap>XXX',
6432 'outerWrap' =>
'<wrap> # </wrap>',
6433 'outerWrap.' => [
'splitChar' =>
'#'],
6448 public function stdWrap_outerWrap(
string $expected,
string $input, array $conf): void
6452 $this->subject->stdWrap_outerWrap($input, $conf)
6464 'standard case' => [
6467 [
'override' =>
'override']
6469 'empty conf does not override' => [
6474 'empty string does not override' => [
6479 'whitespace does not override' => [
6482 [
'override' =>
' ' .
"\t"]
6484 'zero does not override' => [
6489 'false does not override' => [
6492 [
'override' =>
false]
6494 'null does not override' => [
6497 [
'override' =>
null]
6499 'one does override' => [
6504 'minus one does override' => [
6509 'float does override' => [
6512 [
'override' => -0.1]
6514 'true does override' => [
6517 [
'override' =>
true]
6519 'the value is not trimmed' => [
6522 [
'override' =>
"\t" .
'override']
6540 $this->subject->stdWrap_override($content, $conf)
6559 $content = $this->getUniqueId(
'content');
6561 'parseFunc' => $this->getUniqueId(
'parseFunc'),
6562 'parseFunc.' => [$this->getUniqueId(
'parseFunc.')],
6564 $return = $this->getUniqueId(
'return');
6565 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
6566 ->setMethods([
'parseFunc'])->getMock();
6568 ->expects($this->once())
6569 ->method(
'parseFunc')
6570 ->with($content, $conf[
'parseFunc.'], $conf[
'parseFunc'])
6571 ->willReturn($return);
6593 $debugKey =
'/stdWrap/.postCObject';
6594 $content = $this->getUniqueId(
'content');
6596 'postCObject' => $this->getUniqueId(
'postCObject'),
6597 'postCObject.' => [$this->getUniqueId(
'postCObject.')],
6599 $return = $this->getUniqueId(
'return');
6600 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
6601 ->setMethods([
'cObjGetSingle'])->getMock();
6603 ->expects($this->once())
6604 ->method(
'cObjGetSingle')
6605 ->with($conf[
'postCObject'], $conf[
'postCObject.'], $debugKey)
6606 ->willReturn($return);
6626 $content = $this->getUniqueId(
'content');
6628 'postUserFunc' => $this->getUniqueId(
'postUserFunc'),
6629 'postUserFunc.' => [$this->getUniqueId(
'postUserFunc.')],
6631 $return = $this->getUniqueId(
'return');
6632 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
6633 ->setMethods([
'callUserFunction'])->getMock();
6635 ->expects($this->once())
6636 ->method(
'callUserFunction')
6637 ->with($conf[
'postUserFunc'], $conf[
'postUserFunc.'])
6638 ->willReturn($return);
6665 $uniqueHash = $this->getUniqueId(
'uniqueHash');
6666 $substKey =
'INT_SCRIPT.' . $uniqueHash;
6667 $content = $this->getUniqueId(
'content');
6669 'postUserFuncInt' => $this->getUniqueId(
'function'),
6670 'postUserFuncInt.' => [$this->getUniqueId(
'function array')],
6672 $expect =
'<!--' . $substKey .
'-->';
6673 $frontend = $this->getMockBuilder(TypoScriptFrontendController::class)
6674 ->disableOriginalConstructor()->setMethods([
'uniqueHash'])
6676 $frontend->expects($this->once())->method(
'uniqueHash')
6677 ->with()->willReturn($uniqueHash);
6678 $frontend->config = [];
6680 ContentObjectRenderer::class,
6689 'content' => $content,
6690 'postUserFunc' => $conf[
'postUserFuncInt'],
6691 'conf' => $conf[
'postUserFuncInt.'],
6692 'type' =>
'POSTUSERFUNC',
6697 $frontend->config[
'INTincScript'][$substKey]
6716 $debugKey =
'/stdWrap/.preCObject';
6717 $content = $this->getUniqueId(
'content');
6719 'preCObject' => $this->getUniqueId(
'preCObject'),
6720 'preCObject.' => [$this->getUniqueId(
'preCObject.')],
6722 $return = $this->getUniqueId(
'return');
6723 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
6724 ->setMethods([
'cObjGetSingle'])->getMock();
6726 ->expects($this->once())
6727 ->method(
'cObjGetSingle')
6728 ->with($conf[
'preCObject'], $conf[
'preCObject.'], $debugKey)
6729 ->willReturn($return);
6751 $content = $this->getUniqueId(
'content');
6753 'preIfEmptyListNum' => $this->getUniqueId(
'preIfEmptyListNum'),
6754 'preIfEmptyListNum.' => [
6755 'splitChar' => $this->getUniqueId(
'splitChar')
6758 $return = $this->getUniqueId(
'return');
6759 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
6760 ->setMethods([
'listNum'])->getMock();
6762 ->expects($this->once())
6766 $conf[
'preIfEmptyListNum'],
6767 $conf[
'preIfEmptyListNum.'][
'splitChar']
6769 ->willReturn($return);
6783 $content = $this->getUniqueId(
'content');
6784 $will = $this->getUniqueId(
'will');
6785 $conf[
'prefixComment'] = $this->getUniqueId(
'prefixComment');
6787 $emptyConf2[
'prefixComment'] =
'';
6789 'standard case' => [$will, $content, $conf,
false, 1, $will],
6790 'emptyConf1' => [$content, $content, $emptyConf1,
false, 0, $will],
6791 'emptyConf2' => [$content, $content, $emptyConf2,
false, 0, $will],
6792 'disabled by bool' => [$content, $content, $conf,
true, 0, $will],
6793 'disabled by int' => [$content, $content, $conf, 1, 0, $will],
6828 $this->frontendControllerMock
6829 ->config[
'config'][
'disablePrefixComment'] = $disable;
6830 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
6831 ->setMethods([
'prefixComment'])->getMock();
6833 ->expects($this->exactly($times))
6834 ->method(
'prefixComment')
6835 ->with($conf[
'prefixComment'] ??
null, [], $content)
6836 ->willReturn($will);
6858 $debugKey =
'/stdWrap/.prepend';
6859 $content = $this->getUniqueId(
'content');
6861 'prepend' => $this->getUniqueId(
'prepend'),
6862 'prepend.' => [$this->getUniqueId(
'prepend.')],
6864 $return = $this->getUniqueId(
'return');
6865 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
6866 ->setMethods([
'cObjGetSingle'])->getMock();
6868 ->expects($this->once())
6869 ->method(
'cObjGetSingle')
6870 ->with($conf[
'prepend'], $conf[
'prepend.'], $debugKey)
6871 ->willReturn($return);
6886 'priority of *' => [
'7',
'1 + 2 * 3', []],
6887 'priority of parentheses' => [
'9',
'(1 + 2) * 3', []],
6888 'float' => [
'1.5',
'3/2', []],
6889 'intval casts to int' => [1,
'3/2', [
'prioriCalc' =>
'intval']],
6890 'intval does not round' => [2,
'2.7', [
'prioriCalc' =>
'intval']],
6916 $result = $this->subject->stdWrap_prioriCalc($content, $conf);
6917 $this->assertSame($expect, $result);
6935 $content = $this->getUniqueId(
'content');
6937 'preUserFunc' => $this->getUniqueId(
'preUserFunc'),
6938 'preUserFunc.' => [$this->getUniqueId(
'preUserFunc.')],
6940 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
6941 ->setMethods([
'callUserFunction'])->getMock();
6942 $subject->expects($this->once())->method(
'callUserFunction')
6943 ->with($conf[
'preUserFunc'], $conf[
'preUserFunc.'], $content)
6944 ->willReturn(
'return');
6959 'https://typo3.org?id=10' => [
6960 'https%3A%2F%2Ftypo3.org%3Fid%3D10',
6961 'https://typo3.org?id=10',
6963 'https://typo3.org?id=10&foo=bar' => [
6964 'https%3A%2F%2Ftypo3.org%3Fid%3D10%26foo%3Dbar',
6965 'https://typo3.org?id=10&foo=bar',
6982 $this->subject->stdWrap_rawUrlEncode($content)
7000 $content = $this->getUniqueId(
'content');
7002 'replacement' => $this->getUniqueId(
'not used'),
7003 'replacement.' => [$this->getUniqueId(
'replacement.')],
7005 $return = $this->getUniqueId(
'return');
7006 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
7007 ->setMethods([
'replacement'])->getMock();
7009 ->expects($this->once())
7010 ->method(
'replacement')
7011 ->with($content, $conf[
'replacement.'])
7012 ->willReturn($return);
7028 'empty string is empty' => [
'',
true,
''],
7029 'null is empty' => [
'',
true,
null],
7030 'false is empty' => [
'',
true,
false],
7033 'blank is not empty' => [
' ',
false,
' '],
7034 'tab is not empty' => [
"\t",
false,
"\t"],
7035 'linebreak is not empty' => [PHP_EOL,
false, PHP_EOL],
7036 '"0" is not empty' => [
'0',
false,
'0'],
7037 '0 is not empty' => [0,
false, 0],
7038 '1 is not empty' => [1,
false, 1],
7039 'true is not empty' => [
true,
false,
true],
7061 $subject->_set(
'stdWrapRecursionLevel', 1);
7062 $subject->_set(
'stopRendering', [1 =>
false]);
7064 $this->assertSame($stop,
$subject->_get(
'stopRendering')[1]);
7081 $content = $this->getUniqueId(
'content');
7083 'round' => $this->getUniqueId(
'not used'),
7084 'round.' => [$this->getUniqueId(
'round.')],
7086 $return = $this->getUniqueId(
'return');
7087 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
7088 ->setMethods([
'round'])->getMock();
7090 ->expects($this->once())
7092 ->with($content, $conf[
'round.'])
7093 ->willReturn($return);
7104 $content = $this->getUniqueId(
'content');
7105 $this->assertNotSame($content, $this->subject->getData(
'current'));
7108 $this->subject->stdWrap_setContentToCurrent($content)
7110 $this->assertSame($content, $this->subject->getData(
'current'));
7127 [
'setCurrent' =>
''],
7129 'non-empty string' => [
7131 [
'setCurrent' =>
'xxx'],
7135 [
'setCurrent' => 0],
7137 'integer not null' => [
7139 [
'setCurrent' => 1],
7143 [
'setCurrent' =>
true],
7145 'boolean false' => [
7147 [
'setCurrent' =>
false],
7162 if (isset($conf[
'setCurrent'])) {
7163 $this->assertNotSame($conf[
'setCurrent'], $this->subject->getData(
'current'));
7165 $this->assertSame($input, $this->subject->stdWrap_setCurrent($input, $conf));
7166 if (isset($conf[
'setCurrent'])) {
7167 $this->assertSame($conf[
'setCurrent'], $this->subject->getData(
'current'));
7185 $content = $this->getUniqueId(
'content');
7187 'split' => $this->getUniqueId(
'not used'),
7188 'split.' => [$this->getUniqueId(
'split.')],
7190 $return = $this->getUniqueId(
'return');
7191 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
7192 ->setMethods([
'splitObj'])->getMock();
7194 ->expects($this->once())
7195 ->method(
'splitObj')
7196 ->with($content, $conf[
'split.'])
7197 ->willReturn($return);
7217 $content = $this->getUniqueId(
'content');
7219 'stdWrap' => $this->getUniqueId(
'not used'),
7220 'stdWrap.' => [$this->getUniqueId(
'stdWrap.')],
7222 $return = $this->getUniqueId(
'return');
7223 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
7224 ->setMethods([
'stdWrap'])->getMock();
7226 ->expects($this->once())
7228 ->with($content, $conf[
'stdWrap.'])
7229 ->willReturn($return);
7241 'only key returns value' => [
7249 'array without key returns empty string' => [
7257 'array without key returns default' => [
7265 'non existing key returns default' => [
7268 'noTrimWrap' =>
'test',
7269 'noTrimWrap.' =>
'1',
7274 'existing key and array returns stdWrap' => [
7278 'test.' => [
'case' =>
'upper'],
7296 array $configuration,
7297 string $defaultValue,
7300 $result = $this->subject->stdWrapValue($key, $configuration, $defaultValue);
7301 $this->assertEquals($expected, $result);
7312 'pad string with default settings and length 10' => [
7319 'pad string with padWith -= and type left and length 10' => [
7328 'pad string with padWith _ and type both and length 10' => [
7337 'pad string with padWith 0 and type both and length 10' => [
7346 'pad string with padWith ___ and type both and length 6' => [
7355 'pad string with padWith _ and type both and length 12, using stdWrap for length' => [
7367 'pad string with padWith _ and type both and length 12, using stdWrap for padWidth' => [
7379 'pad string with padWith _ and type both and length 12, using stdWrap for type' => [
7388 'substring' =>
'2,1',
7405 public function stdWrap_strPad(
string $expect,
string $content, array $conf): void
7407 $conf = [
'strPad.' => $conf];
7408 $result = $this->subject->stdWrap_strPad($content, $conf);
7409 $this->assertSame($expect, $result);
7422 'given timestamp' => [
7425 [
'strftime' =>
'%d-%m-%Y'],
7431 [
'strftime' =>
'%d-%m-%Y'],
7437 [
'strftime' =>
'%d-%m-%Y'],
7453 public function stdWrap_strftime(
string $expect, $content, array $conf,
int $now): void
7457 $timezoneBackup = date_default_timezone_get();
7458 date_default_timezone_set(
'UTC');
7461 $result = $this->subject->stdWrap_strftime($content, $conf);
7464 date_default_timezone_set($timezoneBackup);
7466 $this->assertSame($expect, $result);
7476 $content =
'<html><p>Hello <span class="inline">inline tag<span>!</p><p>Hello!</p></html>';
7477 $expected =
'Hello inline tag!Hello!';
7478 $this->assertSame($expected, $this->subject->stdWrap_stripHtml($content));
7489 'date from content' => [
7492 [
'strtotime' =>
'1']
7494 'manipulation of date from content' => [
7497 [
'strtotime' =>
'+ 2 weekdays']
7499 'date from configuration' => [
7502 [
'strtotime' =>
'2014-12-04']
7504 'manipulation of date from configuration' => [
7507 [
'strtotime' =>
'2014-12-04 + 2 weekdays']
7512 [
'strtotime' =>
'1']
7514 'date from content and configuration' => [
7517 [
'strtotime' =>
'2014-12-05']
7537 $timezoneBackup = date_default_timezone_get();
7538 date_default_timezone_set(
'UTC');
7540 $result = $this->subject->stdWrap_strtotime($content, $conf);
7543 date_default_timezone_set($timezoneBackup);
7545 $this->assertEquals($expect, $result);
7562 $content = $this->getUniqueId(
'content');
7564 'substring' => $this->getUniqueId(
'substring'),
7565 'substring.' => $this->getUniqueId(
'not used'),
7567 $return = $this->getUniqueId(
'return');
7568 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
7569 ->setMethods([
'substring'])->getMock();
7571 ->expects($this->once())
7572 ->method(
'substring')
7573 ->with($content, $conf[
'substring'])
7574 ->willReturn($return);
7590 'empty string' => [
'',
''],
7591 'string without whitespace' => [
'xxx',
'xxx'],
7592 'string with whitespace inside' => [
7593 'xx ' .
"\t" .
' xx',
7594 'xx ' .
"\t" .
' xx',
7596 'string with newlines inside' => [
7597 'xx ' . PHP_EOL .
' xx',
7598 'xx ' . PHP_EOL .
' xx',
7601 'blanks around' => [
'xxx',
' xxx '],
7602 'tabs around' => [
'xxx',
"\t" .
'xxx' .
"\t"],
7603 'newlines around' => [
'xxx', PHP_EOL .
'xxx' . PHP_EOL],
7604 'mixed case' => [
'xxx',
"\t" .
' xxx ' . PHP_EOL],
7606 'null' => [
'',
null],
7607 'false' => [
'',
false],
7608 'true' => [
'1',
true],
7612 '0.0' => [
'0', 0.0],
7613 '1.0' => [
'1', 1.0],
7614 '-1.0' => [
'-1', -1.0],
7615 '1.1' => [
'1.1', 1.1],
7639 public function stdWrap_trim(
string $expect, $content): void
7641 $result = $this->subject->stdWrap_trim($content);
7642 $this->assertSame($expect, $result);
7658 $content = $this->getUniqueId(
'content');
7660 'typolink' => $this->getUniqueId(
'not used'),
7661 'typolink.' => [$this->getUniqueId(
'typolink.')],
7663 $return = $this->getUniqueId(
'return');
7664 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
7665 ->setMethods([
'typolink'])->getMock();
7667 ->expects($this->once())
7668 ->method(
'typolink')
7669 ->with($content, $conf[
'typolink.'])
7670 ->willReturn($return);
7688 '<wrapper>XXX</wrapper>',
7690 [
'wrap' =>
'<wrapper>|</wrapper>'],
7692 'trims whitespace' => [
7693 '<wrapper>XXX</wrapper>',
7695 [
'wrap' =>
'<wrapper>' .
"\t" .
' | ' .
"\t" .
'</wrapper>'],
7697 'missing pipe puts wrap before' => [
7704 'split char change' => [
7705 '<wrapper>XXX</wrapper>',
7708 'wrap' =>
'<wrapper> # </wrapper>',
7709 'wrap.' => [
'splitChar' =>
'#'],
7712 'split by pattern' => [
7713 '<wrapper>XXX</wrapper>',
7716 'wrap' =>
'<wrapper> ###splitter### </wrapper>',
7717 'wrap.' => [
'splitChar' =>
'###splitter###'],
7732 public function stdWrap_wrap(
string $expected,
string $input, array $conf): void
7736 $this->subject->stdWrap_wrap($input, $conf)
7754 '<wrapper>XXX</wrapper>',
7756 [
'wrap2' =>
'<wrapper>|</wrapper>'],
7758 'trims whitespace' => [
7759 '<wrapper>XXX</wrapper>',
7761 [
'wrap2' =>
'<wrapper>' .
"\t" .
' | ' .
"\t" .
'</wrapper>'],
7763 'missing pipe puts wrap2 before' => [
7770 'split char change' => [
7771 '<wrapper>XXX</wrapper>',
7774 'wrap2' =>
'<wrapper> # </wrapper>',
7775 'wrap2.' => [
'splitChar' =>
'#'],
7778 'split by pattern' => [
7779 '<wrapper>XXX</wrapper>',
7782 'wrap2' =>
'<wrapper> ###splitter### </wrapper>',
7783 'wrap2.' => [
'splitChar' =>
'###splitter###'],
7798 public function stdWrap_wrap2(
string $expected,
string $input, array $conf): void
7800 $this->assertSame($expected, $this->subject->stdWrap_wrap2($input, $conf));
7817 '<wrapper>XXX</wrapper>',
7819 [
'wrap3' =>
'<wrapper>|</wrapper>'],
7821 'trims whitespace' => [
7822 '<wrapper>XXX</wrapper>',
7824 [
'wrap3' =>
'<wrapper>' .
"\t" .
' | ' .
"\t" .
'</wrapper>'],
7826 'missing pipe puts wrap3 before' => [
7833 'split char change' => [
7834 '<wrapper>XXX</wrapper>',
7837 'wrap3' =>
'<wrapper> # </wrapper>',
7838 'wrap3.' => [
'splitChar' =>
'#'],
7841 'split by pattern' => [
7842 '<wrapper>XXX</wrapper>',
7845 'wrap3' =>
'<wrapper> ###splitter### </wrapper>',
7846 'wrap3.' => [
'splitChar' =>
'###splitter###'],
7861 public function stdWrap_wrap3(
string $expected,
string $input, array $conf): void
7863 $this->assertSame($expected, $this->subject->stdWrap_wrap3($input, $conf));
7873 $format =
'<div style="text-align:%s;">%s</div>';
7874 $content = $this->getUniqueId(
'content');
7875 $wrapAlign = $this->getUniqueId(
'wrapAlign');
7876 $expect = sprintf($format, $wrapAlign, $content);
7878 'standard case' => [$expect, $content, $wrapAlign],
7879 'empty conf' => [$content, $content,
null],
7880 'empty string' => [$content, $content,
''],
7881 'whitespaced zero string' => [$content, $content,
' 0 '],
7901 public function stdWrap_wrapAlign(
string $expect,
string $content, $wrapAlignConf): void
7904 if ($wrapAlignConf !==
null) {
7905 $conf[
'wrapAlign'] = $wrapAlignConf;
7909 $this->subject->stdWrap_wrapAlign($content, $conf)
7932 $this->assertEquals(
'tt_content', $this->subject->getCurrentTable());
7942 $content = $this->getUniqueId();
7944 'Handles a tag as wrap.' => [
7945 '<tag>' . $content .
'</tag>',
7949 'Handles simple text as wrap.' => [
7950 'alpha' . $content .
'omega',
7954 'Trims whitespace around tags.' => [
7955 '<tag>' . $content .
'</tag>',
7957 "\t <tag>\t |\t </tag>\t "
7959 'A wrap without pipe is placed before the content.' => [
7964 'For an empty string as wrap the content is returned as is.' => [
7969 'For null as wrap the content is returned as is.' => [
7974 'For a valid rootline level the uid will be inserted.' => [
7975 '<a href="?id=55">' . $content .
'</a>',
7977 '<a href="?id={3}"> | </a>'
7979 'For an invalid rootline level there is no replacement.' => [
7980 '<a href="?id={4}">' . $content .
'</a>',
7982 '<a href="?id={4}"> | </a>'
7996 public function linkWrap(
string $expected,
string $content, $wrap): void
7998 $this->templateServiceMock->rootLine = [3 => [
'uid' => 55]];
7999 $actual = $this->subject->linkWrap($content, $wrap);
8000 $this->assertEquals($expected, $actual);
8010 $comment = $this->getUniqueId();
8011 $content = $this->getUniqueId();
8013 $format .=
'%%s<!-- %%s [begin] -->%s';
8014 $format .=
'%%s%s%%s%s';
8015 $format .=
'%%s<!-- %%s [end] -->%s';
8017 $format = sprintf($format, LF, LF,
"\t", LF, LF,
"\t");
8019 $indent2 =
"\t" .
"\t";
8021 'indent one tab' => [
8035 'indent two tabs' => [
8049 'htmlspecialchars applies for comment only' => [
8053 '<' . $comment .
'>',
8055 '<' . $content .
'>',
8057 '<' . $comment .
'>',
8060 '1|' .
'<' . $comment .
'>',
8061 '<' . $content .
'>'
8075 public function prefixComment(
string $expect,
string $comment,
string $content): void
8079 $result = $this->subject->prefixComment($comment,
null, $content);
8080 $this->assertEquals($expect, $result);
8090 $storageMock = $this->createMock(ResourceStorage::class);
8091 $file =
new File([
'testfile'], $storageMock);
8092 $this->subject->setCurrentFile($file);
8093 $this->assertSame($file, $this->subject->getCurrentFile());
8107 $key = $this->getUniqueId();
8108 $value = $this->getUniqueId();
8109 $this->subject->currentValKey = $key;
8110 $this->subject->setCurrentVal($value);
8111 $this->assertEquals($value, $this->subject->getCurrentVal());
8112 $this->assertEquals($value, $this->subject->data[$key]);
8122 $value = $this->getUniqueId();
8123 $this->subject->setUserObjectType($value);
8124 $this->assertEquals($value, $this->subject->getUserObjectType());
8135 'Simple email address' => [
8137 'test@email.tld'
8139 'Simple email address with unicode characters' => [
8140 'matthäus@email.tld',
8141 'matthäus@email.tld'
8143 'Susceptible email address' => [
8144 '"><script>alert(\'emailSpamProtection\')</script>',
8145 '"><script>alert('emailSpamProtection')</script>'
8148 'Susceptible email address with unicode characters' => [
8149 '"><script>alert(\'ȅmǡilSpamProtȅction\')</script>',
8150 '"><script>alert('ȅmǡilSpamProtȅction')</script>'
8167 $this->subject->_call(
'encryptEmail', $content,
'ascii')
8181 return new Site(
'test', 1, [
8182 'identifier' =>
'test',
8187 $languageConfiguration,