2 namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject;
56 'TEXT' => \TYPO3\CMS\Frontend\ContentObject\TextContentObject::class,
57 'CASE' => \TYPO3\CMS\Frontend\ContentObject\CaseContentObject::class,
58 'COBJ_ARRAY' => \TYPO3\CMS\Frontend\ContentObject\ContentObjectArrayContentObject::class,
59 'COA' => \TYPO3\CMS\Frontend\ContentObject\ContentObjectArrayContentObject::class,
60 'COA_INT' => \TYPO3\CMS\Frontend\ContentObject\ContentObjectArrayInternalContentObject::class,
61 'USER' => \TYPO3\CMS\Frontend\ContentObject\UserContentObject::class,
62 'USER_INT' => \TYPO3\CMS\Frontend\ContentObject\UserInternalContentObject::class,
63 'FILE' => \TYPO3\CMS\Frontend\ContentObject\FileContentObject::class,
64 'FILES' => \TYPO3\CMS\Frontend\ContentObject\FilesContentObject::class,
65 'IMAGE' => \TYPO3\CMS\Frontend\ContentObject\ImageContentObject::class,
66 'IMG_RESOURCE' => \TYPO3\CMS\Frontend\ContentObject\ImageResourceContentObject::class,
67 'CONTENT' => \TYPO3\CMS\Frontend\ContentObject\ContentContentObject::class,
68 'RECORDS' => \TYPO3\CMS\Frontend\ContentObject\RecordsContentObject::class,
69 'HMENU' => \TYPO3\CMS\Frontend\ContentObject\HierarchicalMenuContentObject::class,
70 'CASEFUNC' => \TYPO3\CMS\Frontend\ContentObject\CaseContentObject::class,
71 'LOAD_REGISTER' => \TYPO3\CMS\Frontend\ContentObject\LoadRegisterContentObject::class,
72 'RESTORE_REGISTER' => \TYPO3\CMS\Frontend\ContentObject\RestoreRegisterContentObject::class,
73 'TEMPLATE' => \TYPO3\CMS\Frontend\ContentObject\TemplateContentObject::class,
74 'FLUIDTEMPLATE' => \TYPO3\CMS\Frontend\ContentObject\FluidTemplateContentObject::class,
75 'SVG' => \TYPO3\CMS\Frontend\ContentObject\ScalableVectorGraphicsContentObject::class,
76 'EDITPANEL' => \TYPO3\CMS\Frontend\ContentObject\EditPanelContentObject::class
84 $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
87 $this->templateServiceMock = $this->getMock(\TYPO3\CMS\Core\TypoScript\TemplateService::class, array(
'getFileName',
'linkData'));
88 $pageRepositoryMock = $this->getMock(\TYPO3\CMS\Frontend\Page\PageRepository::class, array(
'getRawRecord'));
90 $this->typoScriptFrontendControllerMock = $this->getAccessibleMock(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class, array(
'dummy'), array(),
'',
false);
92 $this->typoScriptFrontendControllerMock->config = array();
93 $this->typoScriptFrontendControllerMock->page = array();
94 $this->typoScriptFrontendControllerMock->sys_page = $pageRepositoryMock;
96 $this->typoScriptFrontendControllerMock->renderCharset =
'utf-8';
99 $GLOBALS[
'TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array());
100 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
't3lib_cs_utils'] =
'mbstring';
102 $this->subject = $this->getAccessibleMock(
103 \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class,
104 array(
'getResourceFactory',
'getEnvironmentVariable'),
105 array($this->typoScriptFrontendControllerMock)
107 $this->subject->setContentObjectClassMap($this->contentObjectMap);
108 $this->subject->start(array(),
'tt_content');
126 $logManagerMock = $this->getMock(LogManager::class);
127 $loggerMock = $this->getMock(LoggerInterface::class);
128 $logManagerMock->expects($this->any())
129 ->method(
'getLogger')
130 ->willReturn($loggerMock);
143 $GLOBALS[
'TSFE']->renderCharset = $charset;
145 $expected =
$GLOBALS[
'TSFE']->csConvObj->conv($expected,
'iso-8859-1', $charset);
156 $this->templateServiceMock
157 ->expects($this->atLeastOnce())
158 ->method(
'getFileName')
159 ->with(
'typo3/clear.gif')
160 ->will($this->returnValue(
'typo3/clear.gif'));
162 $resourceFactory = $this->getMock(\TYPO3\CMS\Core\Resource\ResourceFactory::class, array(), array(),
'',
false);
163 $this->subject->expects($this->any())->method(
'getResourceFactory')->will($this->returnValue($resourceFactory));
165 $className = $this->getUniqueId(
'tx_coretest');
166 $getImgResourceHookMock = $this->getMock(\TYPO3\CMS\Frontend\ContentObject\ContentObjectGetImageResourceHookInterface::class, array(
'getImgResourcePostProcess'), array(), $className);
167 $getImgResourceHookMock
168 ->expects($this->once())
169 ->method(
'getImgResourcePostProcess')
170 ->will($this->returnCallback(array($this,
'isGetImgResourceHookCalledCallback')));
171 $getImgResourceHookObjects = array($getImgResourceHookMock);
172 $this->subject->_setRef(
'getImgResourceHookObjects', $getImgResourceHookObjects);
173 $this->subject->getImgResource(
'typo3/clear.gif', array());
184 list($file, $fileArray, $imageResource, $parent) = func_get_args();
185 $this->assertEquals(
'typo3/clear.gif', $file);
186 $this->assertEquals(
'typo3/clear.gif', $imageResource[
'origFile']);
187 $this->assertTrue(is_array($fileArray));
189 return $imageResource;
199 $dataProvider = array();
200 foreach ($this->contentObjectMap as $name => $className) {
201 $dataProvider[] = array($name, $className);
203 return $dataProvider;
214 $contentObjectInstance = $this->getMock($fullClassName, array(), array(),
'',
false);
215 \TYPO3\CMS\Core\Utility\GeneralUtility::addInstance($fullClassName, $contentObjectInstance);
216 $this->assertSame($contentObjectInstance, $this->subject->getContentObject($name));
227 $this->subject->expects($this->any())->method(
'getEnvironmentVariable')->with($this->equalTo(
'QUERY_STRING'))->will(
228 $this->returnValue(
'key1=value1&key2=value2&key3[key31]=value31&key3[key32][key321]=value321&key3[key32][key322]=value322')
230 $getQueryArgumentsConfiguration = array();
231 $getQueryArgumentsConfiguration[
'exclude'] = array();
232 $getQueryArgumentsConfiguration[
'exclude'][] =
'key1';
233 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key31]';
234 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key32][key321]';
235 $getQueryArgumentsConfiguration[
'exclude'] = implode(
',', $getQueryArgumentsConfiguration[
'exclude']);
237 $actualResult = $this->subject->getQueryArguments($getQueryArgumentsConfiguration);
238 $this->assertEquals($expectedResult, $actualResult);
250 'key31' =>
'value31',
252 'key321' =>
'value321',
253 'key322' =>
'value322'
257 $getQueryArgumentsConfiguration = array();
258 $getQueryArgumentsConfiguration[
'method'] =
'GET';
259 $getQueryArgumentsConfiguration[
'exclude'] = array();
260 $getQueryArgumentsConfiguration[
'exclude'][] =
'key1';
261 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key31]';
262 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key32][key321]';
263 $getQueryArgumentsConfiguration[
'exclude'] = implode(
',', $getQueryArgumentsConfiguration[
'exclude']);
265 $actualResult = $this->subject->getQueryArguments($getQueryArgumentsConfiguration);
266 $this->assertEquals($expectedResult, $actualResult);
274 $this->subject->expects($this->any())->method(
'getEnvironmentVariable')->with($this->equalTo(
'QUERY_STRING'))->will(
275 $this->returnValue(
'key1=value1')
277 $getQueryArgumentsConfiguration = array();
278 $overruleArguments = array(
280 'key1' =>
'value1Overruled',
282 'key2' =>
'value2Overruled'
284 $expectedResult =
'&key1=value1Overruled';
285 $actualResult = $this->subject->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments);
286 $this->assertEquals($expectedResult, $actualResult);
298 'key31' =>
'value31',
300 'key321' =>
'value321',
301 'key322' =>
'value322'
305 $getQueryArgumentsConfiguration = array();
306 $getQueryArgumentsConfiguration[
'method'] =
'POST';
307 $getQueryArgumentsConfiguration[
'exclude'] = array();
308 $getQueryArgumentsConfiguration[
'exclude'][] =
'key1';
309 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key31]';
310 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key32][key321]';
311 $getQueryArgumentsConfiguration[
'exclude'] = implode(
',', $getQueryArgumentsConfiguration[
'exclude']);
312 $overruleArguments = array(
314 'key2' =>
'value2Overruled',
318 'key321' =>
'value321Overruled',
320 'key322' =>
'value322Overruled',
322 'key323' =>
'value323Overruled'
327 $actualResult = $this->subject->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments);
328 $this->assertEquals($expectedResult, $actualResult);
336 $this->subject->expects($this->any())->method(
'getEnvironmentVariable')->with($this->equalTo(
'QUERY_STRING'))->will(
337 $this->returnValue(
'key1=value1&key2=value2&key3[key31]=value31&key3[key32][key321]=value321&key3[key32][key322]=value322')
343 'key31' =>
'value31',
345 'key321' =>
'value321',
346 'key322' =>
'value322'
350 $getQueryArgumentsConfiguration = array();
351 $getQueryArgumentsConfiguration[
'exclude'] = array();
352 $getQueryArgumentsConfiguration[
'exclude'][] =
'key1';
353 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key31]';
354 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key32][key321]';
355 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key32][key322]';
356 $getQueryArgumentsConfiguration[
'exclude'] = implode(
',', $getQueryArgumentsConfiguration[
'exclude']);
357 $overruleArguments = array(
359 'key2' =>
'value2Overruled',
363 'key321' =>
'value321Overruled',
365 'key323' =>
'value323Overruled'
369 $expectedResult = $this->
rawUrlEncodeSquareBracketsInUrl(
'&key2=value2Overruled&key3[key32][key321]=value321Overruled&key3[key32][key323]=value323Overruled');
370 $actualResult = $this->subject->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments,
true);
371 $this->assertEquals($expectedResult, $actualResult);
372 $getQueryArgumentsConfiguration[
'method'] =
'POST';
373 $actualResult = $this->subject->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments,
true);
374 $this->assertEquals($expectedResult, $actualResult);
389 'key331' =>
'POST331',
390 'key332' =>
'POST332',
399 'key331' =>
'GET331',
403 $getQueryArgumentsConfiguration = array();
404 $getQueryArgumentsConfiguration[
'method'] =
'POST,GET';
405 $expectedResult = $this->
rawUrlEncodeSquareBracketsInUrl(
'&key1=POST1&key2=GET2&key3[key31]=POST31&key3[key32]=GET32&key3[key33][key331]=GET331&key3[key33][key332]=POST332');
406 $actualResult = $this->subject->getQueryArguments($getQueryArgumentsConfiguration);
407 $this->assertEquals($expectedResult, $actualResult);
422 'key331' =>
'GET331',
423 'key332' =>
'GET332',
432 'key331' =>
'POST331',
436 $getQueryArgumentsConfiguration = array();
437 $getQueryArgumentsConfiguration[
'method'] =
'GET,POST';
438 $expectedResult = $this->
rawUrlEncodeSquareBracketsInUrl(
'&key1=GET1&key2=POST2&key3[key31]=GET31&key3[key32]=POST32&key3[key33][key331]=POST331&key3[key33][key332]=GET332');
439 $actualResult = $this->subject->getQueryArguments($getQueryArgumentsConfiguration);
440 $this->assertEquals($expectedResult, $actualResult);
451 return str_replace(array(
'[',
']'), array(
'%5B',
'%5D'), $string);
462 $this->assertEquals(
'бла', $this->subject->crop(
'бла',
'3|...'));
477 $plainText =
'Kasper Sk' . chr(229) .
'rh' . chr(248) .
'j implemented the original version of the crop function.';
478 $textWithMarkup =
'<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) .
'rh' . chr(248) .
'j</a>' .
' implemented</strong> the original version of the crop function.';
479 $textWithEntities =
'Kasper Skårhøj implemented the; original ' .
'version of the crop function.';
480 $charsets = array(
'iso-8859-1',
'utf-8',
'ascii',
'big5');
482 foreach ($charsets as $charset) {
483 $data = array_merge($data, array(
484 $charset .
' plain text; 11|...' => array(
487 'Kasper Sk' . chr(229) .
'r...',
490 $charset .
' plain text; -58|...' => array(
493 '...h' . chr(248) .
'j implemented the original version of the crop function.',
496 $charset .
' plain text; 4|...|1' => array(
502 $charset .
' plain text; 20|...|1' => array(
505 'Kasper Sk' . chr(229) .
'rh' . chr(248) .
'j...',
508 $charset .
' plain text; -5|...|1' => array(
514 $charset .
' plain text; -49|...|1' => array(
517 '...the original version of the crop function.',
520 $charset .
' text with markup; 11|...' => array(
523 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) .
'r...</a></strong>',
526 $charset .
' text with markup; 13|...' => array(
529 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) .
'rh' . chr(248) .
'...</a></strong>',
532 $charset .
' text with markup; 14|...' => array(
535 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) .
'rh' . chr(248) .
'j</a>...</strong>',
538 $charset .
' text with markup; 15|...' => array(
541 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) .
'rh' . chr(248) .
'j</a> ...</strong>',
544 $charset .
' text with markup; 29|...' => array(
547 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) .
'rh' . chr(248) .
'j</a> implemented</strong> th...',
550 $charset .
' text with markup; -58|...' => array(
553 '<strong><a href="mailto:kasper@typo3.org">...h' . chr(248) .
'j</a> implemented</strong> the original version of the crop function.',
556 $charset .
' text with markup 4|...|1' => array(
559 '<strong><a href="mailto:kasper@typo3.org">Kasp...</a></strong>',
562 $charset .
' text with markup; 11|...|1' => array(
565 '<strong><a href="mailto:kasper@typo3.org">Kasper...</a></strong>',
568 $charset .
' text with markup; 13|...|1' => array(
571 '<strong><a href="mailto:kasper@typo3.org">Kasper...</a></strong>',
574 $charset .
' text with markup; 14|...|1' => array(
577 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) .
'rh' . chr(248) .
'j</a>...</strong>',
580 $charset .
' text with markup; 15|...|1' => array(
583 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) .
'rh' . chr(248) .
'j</a>...</strong>',
586 $charset .
' text with markup; 29|...|1' => array(
589 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) .
'rh' . chr(248) .
'j</a> implemented</strong>...',
592 $charset .
' text with markup; -66|...|1' => array(
595 '<strong><a href="mailto:kasper@typo3.org">...Sk' . chr(229) .
'rh' . chr(248) .
'j</a> implemented</strong> the original version of the crop function.',
598 $charset .
' text with entities 9|...' => array(
604 $charset .
' text with entities 10|...' => array(
607 'Kasper Skå...',
610 $charset .
' text with entities 11|...' => array(
613 'Kasper Skår...',
616 $charset .
' text with entities 13|...' => array(
619 'Kasper Skårhø...',
622 $charset .
' text with entities 14|...' => array(
625 'Kasper Skårhøj...',
628 $charset .
' text with entities 15|...' => array(
631 'Kasper Skårhøj ...',
634 $charset .
' text with entities 16|...' => array(
637 'Kasper Skårhøj i...',
640 $charset .
' text with entities -57|...' => array(
643 '...j implemented the; original version of the crop function.',
646 $charset .
' text with entities -58|...' => array(
649 '...øj implemented the; original version of the crop function.',
652 $charset .
' text with entities -59|...' => array(
655 '...høj implemented the; original version of the crop function.',
658 $charset .
' text with entities 4|...|1' => array(
664 $charset .
' text with entities 9|...|1' => array(
670 $charset .
' text with entities 10|...|1' => array(
676 $charset .
' text with entities 11|...|1' => array(
682 $charset .
' text with entities 13|...|1' => array(
688 $charset .
' text with entities 14|...|1' => array(
691 'Kasper Skårhøj...',
694 $charset .
' text with entities 15|...|1' => array(
697 'Kasper Skårhøj...',
700 $charset .
' text with entities 16|...|1' => array(
703 'Kasper Skårhøj...',
706 $charset .
' text with entities -57|...|1' => array(
709 '...implemented the; original version of the crop function.',
712 $charset .
' text with entities -58|...|1' => array(
715 '...implemented the; original version of the crop function.',
718 $charset .
' text with entities -59|...|1' => array(
721 '...implemented the; original version of the crop function.',
724 $charset .
' text with dash in html-element 28|...|1' => array(
726 'Some text with a link to <link email.address@example.org - mail "Open email window">my email.address@example.org</link> and text after it',
727 'Some text with a link to <link email.address@example.org - mail "Open email window">my...</link>',
730 $charset .
' html elements with dashes in attributes' => array(
732 '<em data-foo="x">foobar</em>foobaz',
733 '<em data-foo="x">foobar</em>foo',
736 $charset .
' html elements with iframe embedded 24|...|1' => array(
738 'Text with iframe <iframe src="//what.ever/"></iframe> and text after it',
739 'Text with iframe <iframe src="//what.ever/"></iframe> and...',
742 $charset .
' html elements with script tag embedded 24|...|1' => array(
744 'Text with script <script>alert(\'foo\');</script> and text after it',
745 'Text with script <script>alert(\'foo\');</script> and...',
766 $this->assertEquals($expected, $this->subject->cropHTML(
$subject, $settings),
'cropHTML failed with settings: "' . $settings .
'" and charset "' . $charset .
'"');
777 $GLOBALS[
'TSFE']->renderCharset =
'iso-8859-1';
779 '<h1>Blog Example</h1>' . LF .
781 '<div class="csc-header csc-header-n1">' . LF .
782 ' <h2 class="csc-firstHeader">Welcome to Blog #1</h2>' . LF .
784 '<p class="bodytext">' . LF .
785 ' A blog about TYPO3 extension development. In order to start blogging, read the <a href="#">Help section</a>. If you have any further questions, feel free to contact the administrator John Doe (<a href="mailto:john.doe@example.com">john.doe@example.com)</a>.' . LF .
787 '<div class="tx-blogexample-list-container">' . LF .
788 ' <p class="bodytext">' . LF .
789 ' Below are the most recent posts:' . LF .
792 ' <li data-element="someId">' . LF .
794 ' <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[blog]=&tx_blogexample_pi1[action]=show&tx_blogexample_pi1[controller]=Post&cHash=003b0131ed">The Post #1</a>' . LF .
796 ' <p class="bodytext">' . LF .
797 ' Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut...' . LF .
799 ' <p class="metadata">' . LF .
800 ' Published on 26.08.2009 by Jochen Rau' . LF .
803 ' Tags: [MVC] [Domain Driven Design] <br>' . LF .
804 ' <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[action]=show&tx_blogexample_pi1[controller]=Post&cHash=f982643bc3">read more >></a><br>' . LF .
805 ' <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[blog][uid]=70&tx_blogexample_pi1[action]=edit&tx_blogexample_pi1[controller]=Post&cHash=5b481bc8f0">Edit</a> <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[blog][uid]=70&tx_blogexample_pi1[action]=delete&tx_blogexample_pi1[controller]=Post&cHash=4e52879656">Delete</a>' . LF .
810 ' <a href="index.php?id=99&tx_blogexample_pi1[blog][uid]=70&tx_blogexample_pi1[action]=new&tx_blogexample_pi1[controller]=Post&cHash=2718a4b1a0">Create a new Post</a>' . LF .
815 ' ? TYPO3 Association' . LF .
818 $result = $this->subject->cropHTML($input,
'300');
821 '<h1>Blog Example</h1>' . LF .
823 '<div class="csc-header csc-header-n1">' . LF .
824 ' <h2 class="csc-firstHeader">Welcome to Blog #1</h2>' . LF .
826 '<p class="bodytext">' . LF .
827 ' A blog about TYPO3 extension development. In order to start blogging, read the <a href="#">Help section</a>. If you have any further questions, feel free to contact the administrator John Doe (<a href="mailto:john.doe@example.com">john.doe@example.com)</a>.' . LF .
829 '<div class="tx-blogexample-list-container">' . LF .
830 ' <p class="bodytext">' . LF .
831 ' Below are the most recent posts:' . LF .
834 ' <li data-element="someId">' . LF .
836 ' <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[blog]=&tx_blogexample_pi1[action]=show&tx_blogexample_pi1[controller]=Post&cHash=003b0131ed">The Post</a></h3></li></ul></div>';
838 $this->assertEquals($expected, $result);
840 $result = $this->subject->cropHTML($input,
'-100');
843 '<div class="tx-blogexample-list-container"><ul><li data-element="someId"><p> Design] <br>' . LF .
844 ' <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[action]=show&tx_blogexample_pi1[controller]=Post&cHash=f982643bc3">read more >></a><br>' . LF .
845 ' <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[blog][uid]=70&tx_blogexample_pi1[action]=edit&tx_blogexample_pi1[controller]=Post&cHash=5b481bc8f0">Edit</a> <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[blog][uid]=70&tx_blogexample_pi1[action]=delete&tx_blogexample_pi1[controller]=Post&cHash=4e52879656">Delete</a>' . LF .
850 ' <a href="index.php?id=99&tx_blogexample_pi1[blog][uid]=70&tx_blogexample_pi1[action]=new&tx_blogexample_pi1[controller]=Post&cHash=2718a4b1a0">Create a new Post</a>' . LF .
855 ' ? TYPO3 Association' . LF .
858 $this->assertEquals($expected, $result);
868 $subject =
"Lorem ipsum dolor sit amet,\nconsetetur sadipscing elitr,\nsed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam";
869 $expected =
"Lorem ipsum dolor sit amet,\nconsetetur sadipscing elitr,\nsed diam nonumy eirmod tempor invidunt ut labore et dolore magna";
870 $result = $this->subject->cropHTML(
$subject,
'121');
871 $this->assertEquals($expected, $result);
880 'rounding off without any configuration' => array(
885 'rounding up without any configuration' => array(
890 'regular rounding (off) to two decimals' => array(
897 'regular rounding (up) to two decimals' => array(
904 'rounding up to integer with type ceil' => array(
907 'roundType' =>
'ceil'
911 'rounding down to integer with type floor' => array(
914 'roundType' =>
'floor'
936 $result = $this->subject->stdWrap_round($float, $conf);
937 $this->assertEquals($expected, $result);
946 'testing decimals' => array(
949 'numberFormat.' => array(
955 'testing decimals with input as string' => array(
958 'numberFormat.' => array(
964 'testing dec_point' => array(
967 'numberFormat.' => array(
974 'testing thousands_sep' => array(
977 'numberFormat.' => array(
979 'thousands_sep.' => array(
986 'testing mixture' => array(
989 'numberFormat.' => array(
991 'dec_point.' => array(
994 'thousands_sep.' => array(
1016 $result = $this->subject->stdWrap_numberFormat($float, $conf);
1017 $this->assertEquals($expected, $result);
1034 'numbers and range' => array(
1052 $result = $this->subject->stdWrap_expandList($content);
1053 $this->assertEquals($expected, $result);
1062 'trimstring' => array(
1066 'trim string with space inside' => array(
1070 'trim string with space at the begin and end' => array(
1088 $result = $this->subject->stdWrap_trim($content);
1089 $this->assertEquals($expected, $result);
1122 'bool TRUE' => array(
1126 'bool FALSE' => array(
1144 $result = $this->subject->stdWrap_intval($content);
1145 $this->assertEquals($expected, $result);
1154 'pad string with default settings and length 10' => array(
1161 'pad string with padWith -= and type left and length 10' => array(
1170 'pad string with padWith _ and type both and length 10' => array(
1179 'pad string with padWith 0 and type both and length 10' => array(
1188 'pad string with padWith ___ and type both and length 6' => array(
1197 'pad string with padWith _ and type both and length 12, using stdWrap for length' => array(
1209 'pad string with padWith _ and type both and length 12, using stdWrap for padWidth' => array(
1214 'padWith.' => array(
1221 'pad string with padWith _ and type both and length 12, using stdWrap for type' => array(
1229 'substring' =>
'2,1',
1253 $result = $this->subject->stdWrap_strPad($content, $conf);
1254 $this->assertEquals($expected, $result);
1266 'testing md5' => array(
1271 'bacb98acf97e0b6112b1d1b650b84971'
1273 'testing sha1' => array(
1278 '063b3d108bed9f88fa618c6046de0dccadcf3158'
1280 'testing non-existing hashing algorithm' => array(
1283 'hash' =>
'non-existing'
1287 'testing stdWrap capability' => array(
1291 'cObject' =>
'TEXT',
1292 'cObject.' => array(
1297 'bacb98acf97e0b6112b1d1b650b84971'
1315 $result = $this->subject->stdWrap_hash($text, $conf);
1316 $this->assertEquals($expected, $result);
1324 $stdWrapConfiguration = array(
1325 'noTrimWrap' =>
'|| 123|',
1326 'stdWrap.' => array(
1327 'wrap' =>
'<b>|</b>'
1332 $this->subject->stdWrap(
'Test', $stdWrapConfiguration)
1341 $stdWrapConfiguration = array(
1344 'data' =>
'register:Counter'
1346 'stdWrap.' => array(
1347 'append' =>
'LOAD_REGISTER',
1349 'Counter.' => array(
1350 'prioriCalc' =>
'intval',
1351 'cObject' =>
'TEXT',
1352 'cObject.' => array(
1353 'data' =>
'register:Counter',
1362 $this->subject->stdWrap(
'Counter:', $stdWrapConfiguration)
1375 'testing decimals' => array(
1382 'testing decimals with input as string' => array(
1389 'testing dec_point' => array(
1397 'testing thousands_sep' => array(
1401 'thousands_sep.' => array(
1407 'testing mixture' => array(
1411 'dec_point.' => array(
1414 'thousands_sep.' => array(
1432 $result = $this->subject->numberFormat($float, $formatConf);
1433 $this->assertEquals($expected, $result);
1445 'multiple replacements, including regex' => array(
1446 'There_is_a_cat,_a_dog_and_a_tiger_in_da_hood!_Yeah!',
1448 'replacement.' => array(
1450 'search' =>
'in da hood',
1451 'replace' =>
'around the block'
1455 'replace.' => array(
'char' =>
'32')
1458 'search' =>
'#a (Cat|Dog|Tiger)#i',
1459 'replace' =>
'an animal',
1464 'There is an animal, an animal and an animal around the block! Yeah!'
1466 'replacement with optionSplit, normal pattern' => array(
1467 'There_is_a_cat,_a_dog_and_a_tiger_in_da_hood!_Yeah!',
1469 'replacement.' => array(
1472 'replace' =>
'1 || 2 || 3',
1473 'useOptionSplitReplace' =>
'1'
1477 'There1is2a3cat,3a3dog3and3a3tiger3in3da3hood!3Yeah!'
1479 'replacement with optionSplit, using regex' => array(
1480 'There is a cat, a dog and a tiger in da hood! Yeah!',
1482 'replacement.' => array(
1484 'search' =>
'#(a) (Cat|Dog|Tiger)#i',
1485 'replace' =>
'${1} tiny ${2} || ${1} midsized ${2} || ${1} big ${2}',
1486 'useOptionSplitReplace' =>
'1',
1491 'There is a tiny cat, a midsized dog and a big tiger in da hood! Yeah!'
1505 $result = $this->subject->stdWrap_replacement($input, $conf);
1506 $this->assertEquals($expected, $result);
1518 'testing empty conf' => array(
1525 'testing #17284: adding uid/pid for workspaces' => array(
1528 'selectFields' =>
'header,bodytext'
1531 'SELECT' =>
'header,bodytext, tt_content.uid as uid, tt_content.pid as pid, tt_content.t3ver_state as t3ver_state'
1534 'testing #17284: no need to add' => array(
1537 'selectFields' =>
'tt_content.*'
1540 'SELECT' =>
'tt_content.*'
1543 'testing #17284: no need to add #2' => array(
1546 'selectFields' =>
'*'
1552 'testing #29783: joined tables, prefix tablename' => array(
1555 'selectFields' =>
'tt_content.header,be_users.username',
1556 'join' =>
'be_users ON tt_content.cruser_id = be_users.uid'
1559 'SELECT' =>
'tt_content.header,be_users.username, tt_content.uid as uid, tt_content.pid as pid, tt_content.t3ver_state as t3ver_state'
1562 'testing #34152: single count(*), add nothing' => array(
1565 'selectFields' =>
'count(*)'
1568 'SELECT' =>
'count(*)'
1571 'testing #34152: single max(crdate), add nothing' => array(
1574 'selectFields' =>
'max(crdate)'
1577 'SELECT' =>
'max(crdate)'
1580 'testing #34152: single min(crdate), add nothing' => array(
1583 'selectFields' =>
'min(crdate)'
1586 'SELECT' =>
'min(crdate)'
1589 'testing #34152: single sum(is_siteroot), add nothing' => array(
1592 'selectFields' =>
'sum(is_siteroot)'
1595 'SELECT' =>
'sum(is_siteroot)'
1598 'testing #34152: single avg(crdate), add nothing' => array(
1601 'selectFields' =>
'avg(crdate)'
1604 'SELECT' =>
'avg(crdate)'
1622 'enablecolumns' => array(
1623 'disabled' =>
'hidden'
1627 'tt_content' => array(
1629 'enablecolumns' => array(
1630 'disabled' =>
'hidden'
1632 'versioningWS' =>
true
1636 $result = $this->subject->getQuery($table, $conf,
true);
1637 foreach ($expected as $field => $value) {
1638 $this->assertEquals($value, $result[$field]);
1650 'enablecolumns' => array(
1651 'disabled' =>
'hidden'
1655 'tt_content' => array(
1657 'enablecolumns' => array(
1658 'disabled' =>
'hidden'
1663 $this->subject = $this->getAccessibleMock(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class, array(
'getTreeList'));
1664 $this->subject->start(array(),
'tt_content');
1666 'recursive' =>
'15',
1667 'pidInList' =>
'16, -35'
1669 $this->subject->expects($this->at(0))
1670 ->method(
'getTreeList')
1672 ->will($this->returnValue(
'15,16'));
1673 $this->subject->expects($this->at(1))
1674 ->method(
'getTreeList')
1676 ->will($this->returnValue(
'15,35'));
1677 $this->subject->getQuery(
'tt_content', $conf,
true);
1688 'enablecolumns' => array(
1689 'disabled' =>
'hidden'
1693 'tt_content' => array(
1695 'enablecolumns' => array(
1696 'disabled' =>
'hidden'
1701 $this->subject = $this->getAccessibleMock(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class, array(
'getTreeList'));
1703 $this->subject->start(array(),
'tt_content');
1705 'pidInList' =>
'this',
1708 $this->subject->expects($this->once())
1709 ->method(
'getTreeList')
1711 ->will($this->returnValue(
'27'));
1712 $this->subject->getQuery(
'tt_content', $conf,
true);
1724 'given timestamp' => array(
1731 'empty string' => array(
1738 'testing null' => array(
1745 'given timestamp return GMT' => array(
1748 'date' =>
'd.m.Y H:i:s',
1753 '02.10.2015 10:00:00',
1768 $GLOBALS[
'EXEC_TIME'] = 1443780000;
1770 $result = $this->subject->stdWrap_date($content, $conf);
1772 $this->assertEquals($expected, $result);
1784 'given timestamp' => array(
1787 'strftime' =>
'%d-%m-%Y',
1790 'empty string' => array(
1793 'strftime' =>
'%d-%m-%Y',
1796 'testing null' => array(
1799 'strftime' =>
'%d-%m-%Y',
1813 $GLOBALS[
'EXEC_TIME'] = 1346500800;
1816 $timezoneBackup = date_default_timezone_get();
1817 date_default_timezone_set(
'UTC');
1819 $result = $this->subject->stdWrap_strftime($content, $conf);
1822 date_default_timezone_set($timezoneBackup);
1824 $this->assertEquals(
'01-09-2012', $result);
1836 'date from content' => array(
1843 'manipulation of date from content' => array(
1846 'strtotime' =>
'+ 2 weekdays',
1850 'date from configuration' => array(
1853 'strtotime' =>
'2014-12-04',
1857 'manipulation of date from configuration' => array(
1860 'strtotime' =>
'2014-12-04 + 2 weekdays',
1864 'empty input' => array(
1871 'date from content and configuration' => array(
1874 'strtotime' =>
'2014-12-05',
1891 $GLOBALS[
'EXEC_TIME'] = 1417392000;
1894 $timezoneBackup = date_default_timezone_get();
1895 date_default_timezone_set(
'UTC');
1897 $result = $this->subject->stdWrap_strtotime($content, $configuration);
1900 date_default_timezone_set($timezoneBackup);
1902 $this->assertEquals($expected, $result);
1911 \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class,
1916 $subject->expects($this->once())->method(
'calcAge')->with(1,
'Min| Hrs| Days| Yrs');
1917 $subject->stdWrap_age(9, array(
'age' =>
'Min| Hrs| Days| Yrs'));
1931 ' min| hrs| days| yrs',
1936 ' min| hrs| days| yrs',
1941 ' min| hrs| days| yrs',
1944 'day with provided singular labels' => array(
1946 ' min| hrs| days| yrs| min| hour| day| year',
1951 ' min| hrs| days| yrs',
1954 'different labels' => array(
1956 ' Minutes| Hrs| Days| Yrs',
1959 'negative values' => array(
1961 ' min| hrs| days| yrs',
1964 'default label values for wrong label input' => array(
1969 'default singular label values for wrong label input' => array(
1986 $result = $this->subject->calcAge($timestamp, $labels);
1987 $this->assertEquals($result, $expectation);
1998 'lower case text to upper' => array(
1999 '<span>text</span>',
2003 '<span>TEXT</span>',
2005 'upper case text to lower' => array(
2006 '<span>TEXT</span>',
2010 '<span>text</span>',
2012 'capitalize text' => array(
2013 '<span>this is a text</span>',
2015 'case' =>
'capitalize',
2017 '<span>This Is A Text</span>',
2019 'ucfirst text' => array(
2020 '<span>this is a text</span>',
2022 'case' =>
'ucfirst',
2024 '<span>This is a text</span>',
2026 'lcfirst text' => array(
2027 '<span>This is a Text</span>',
2029 'case' =>
'lcfirst',
2031 '<span>this is a Text</span>',
2033 'uppercamelcase text' => array(
2034 '<span>this_is_a_text</span>',
2036 'case' =>
'uppercamelcase',
2038 '<span>ThisIsAText</span>',
2040 'lowercamelcase text' => array(
2041 '<span>this_is_a_text</span>',
2043 'case' =>
'lowercamelcase',
2045 '<span>thisIsAText</span>',
2059 $result = $this->subject->stdWrap_case($content, $configuration);
2060 $this->assertEquals($expected, $result);
2071 'only key returns value' => array(
2079 'array without key returns empty string' => array(
2087 'array without key returns default' => array(
2095 'non existing key returns default' => array(
2098 'noTrimWrap' =>
'test',
2099 'noTrimWrap.' =>
'1',
2104 'existing key and array returns stdWrap' => array(
2108 'test.' => array(
'case' =>
'upper'),
2126 $result = $this->subject->stdWrapValue($key, $configuration, $defaultValue);
2127 $this->assertEquals($expected, $result);
2139 $result = $this->subject->stdWrap_ifNull($content, $configuration);
2140 $this->assertEquals($expected, $result);
2151 'null value' => array(
2158 'zero value' => array(
2176 'null value' => array(
2183 'empty value' => array(
2190 'string value' => array(
2197 'empty string value' => array(
2216 $result = $this->subject->stdWrap_ifEmpty($content, $configuration);
2217 $this->assertEquals($expected, $result);
2229 $result = $this->subject->stdWrap_noTrimWrap($content, $configuration);
2230 $this->assertEquals($expected, $result);
2241 'No char given' => array(
2244 'noTrimWrap' =>
'| left | right |',
2246 ' left middle right '
2248 'Zero char given' => array(
2251 'noTrimWrap' =>
'0 left 0 right 0',
2252 'noTrimWrap.' => array(
'splitChar' =>
'0'),
2255 ' left middle right '
2257 'Default char given' => array(
2260 'noTrimWrap' =>
'| left | right |',
2261 'noTrimWrap.' => array(
'splitChar' =>
'|'),
2263 ' left middle right '
2265 'Split char is a' => array(
2268 'noTrimWrap' =>
'a left a right a',
2269 'noTrimWrap.' => array(
'splitChar' =>
'a'),
2271 ' left middle right '
2273 'Split char is multi-char (ab)' => array(
2276 'noTrimWrap' =>
'ab left ab right ab',
2277 'noTrimWrap.' => array(
'splitChar' =>
'ab'),
2279 ' left middle right '
2281 'Split char accepts stdWrap' => array(
2284 'noTrimWrap' =>
'abc left abc right abc',
2285 'noTrimWrap.' => array(
2287 'splitChar.' => array(
'wrap' =>
'a|c'),
2290 ' left middle right '
2303 $this->subject->stdWrap_addPageCacheTags(
'', $configuration);
2304 $this->assertEquals($expectedTags, $this->typoScriptFrontendControllerMock->_get(
'pageCacheTags'));
2315 array(
'addPageCacheTags' =>
''),
2317 'Two expectedTags' => array(
2318 array(
'tag1',
'tag2'),
2319 array(
'addPageCacheTags' =>
'tag1,tag2'),
2321 'Two expectedTags plus one with stdWrap' => array(
2322 array(
'tag1',
'tag2',
'tag3'),
2324 'addPageCacheTags' =>
'tag1,tag2',
2325 'addPageCacheTags.' => array(
'wrap' =>
'|,tag3')
2340 'double quote in string' => array(
2343 '\'double\u0020quote\u0022\
''
2345 'backslash in string' => array(
2348 '\'backslash\u0020\u005C\
''
2350 'exclamation mark' => array(
2353 '\'exclamation\u0021\
''
2355 'whitespace tab, newline and carriage return' => array(
2356 "white\tspace\ns\r",
2358 '\'white\u0009space\u000As\u000D\
''
2360 'single quote in string' => array(
2363 '\'single\u0020quote\u0020\u0027\
''
2368 '\'\u003Ctag\u003E\
''
2370 'ampersand in string' => array(
2373 '\'amper\u0026sand\
''
2386 $result = $this->subject->stdWrap_encodeForJavaScriptValue($input, $conf);
2387 $this->assertEquals($expected, $result);
2401 'Value in get-data' => array(
'onlyInGet',
'GetValue'),
2402 'Value in post-data' => array(
'onlyInPost',
'PostValue'),
2403 'Value in post-data overriding get-data' => array(
'inGetAndPost',
'ValueInPost'),
2416 'onlyInGet' =>
'GetValue',
2417 'inGetAndPost' =>
'ValueInGet',
2420 'onlyInPost' =>
'PostValue',
2421 'inGetAndPost' =>
'ValueInPost',
2423 $this->assertEquals($expectedValue, $this->subject->getData(
'gp:' . $key));
2433 $this->assertEquals(
$GLOBALS[
'TSFE']->renderCharset, $this->subject->getData(
'tsfe:renderCharset'));
2443 $envName = $this->getUniqueId(
'frontendtest');
2444 $value = $this->getUniqueId(
'someValue');
2445 putenv($envName .
'=' . $value);
2446 $this->assertEquals($value, $this->subject->getData(
'getenv:' . $envName));
2456 $this->subject->expects($this->once())->method(
'getEnvironmentVariable')
2457 ->with($this->equalTo(
'SCRIPT_FILENAME'))->will($this->returnValue(
'dummyPath'));
2458 $this->assertEquals(
'dummyPath', $this->subject->getData(
'getindpenv:SCRIPT_FILENAME'));
2469 $value =
'someValue';
2470 $field = array($key => $value);
2472 $this->assertEquals($value, $this->subject->getData(
'field:' . $key, $field));
2483 $key =
'somekey|level1|level2';
2484 $value =
'somevalue';
2485 $field = array(
'somekey' => array(
'level1' => array(
'level2' =>
'somevalue')));
2487 $this->assertEquals($value, $this->subject->getData(
'field:' . $key, $field));
2497 $uid = $this->getUniqueId();
2498 $file = $this->getMock(\TYPO3\CMS\Core\Resource\File::class, array(), array(),
'',
false);
2499 $file->expects($this->once())->method(
'getUid')->will($this->returnValue($uid));
2500 $this->subject->setCurrentFile($file);
2501 $this->assertEquals($uid, $this->subject->getData(
'file:current:uid'));
2511 $key = $this->getUniqueId(
'someKey');
2512 $value = $this->getUniqueId(
'someValue');
2513 $this->subject->parameters[$key] = $value;
2515 $this->assertEquals($value, $this->subject->getData(
'parameters:' . $key));
2525 $key = $this->getUniqueId(
'someKey');
2526 $value = $this->getUniqueId(
'someValue');
2527 $GLOBALS[
'TSFE']->register[$key] = $value;
2529 $this->assertEquals($value, $this->subject->getData(
'register:' . $key));
2540 0 => array(
'uid' => 1,
'title' =>
'title1'),
2541 1 => array(
'uid' => 2,
'title' =>
'title2'),
2542 2 => array(
'uid' => 3,
'title' =>
'title3'),
2545 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline;
2546 $this->assertEquals(2, $this->subject->getData(
'level'));
2556 $this->assertEquals(
$GLOBALS[
'TSFE']->renderCharset, $this->subject->getData(
'global:TSFE|renderCharset'));
2567 0 => array(
'uid' => 1,
'title' =>
'title1'),
2568 1 => array(
'uid' => 2,
'title' =>
'title2'),
2569 2 => array(
'uid' => 3,
'title' =>
''),
2572 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline;
2573 $this->assertEquals(
'', $this->subject->getData(
'leveltitle:-1'));
2575 $this->assertEquals(
'title2', $this->subject->getData(
'leveltitle:-1,slide'));
2586 0 => array(
'uid' => 1,
'title' =>
'title1',
'media' =>
'media1'),
2587 1 => array(
'uid' => 2,
'title' =>
'title2',
'media' =>
'media2'),
2588 2 => array(
'uid' => 3,
'title' =>
'title3',
'media' =>
''),
2591 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline;
2592 $this->assertEquals(
'', $this->subject->getData(
'levelmedia:-1'));
2594 $this->assertEquals(
'media2', $this->subject->getData(
'levelmedia:-1,slide'));
2605 0 => array(
'uid' => 1,
'title' =>
'title1'),
2606 1 => array(
'uid' => 2,
'title' =>
'title2'),
2607 2 => array(
'uid' => 3,
'title' =>
'title3'),
2610 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline;
2611 $this->assertEquals(3, $this->subject->getData(
'leveluid:-1'));
2613 $this->assertEquals(3, $this->subject->getData(
'leveluid:-1,slide'));
2624 0 => array(
'uid' => 1,
'title' =>
'title1',
'testfield' =>
'field1'),
2625 1 => array(
'uid' => 2,
'title' =>
'title2',
'testfield' =>
'field2'),
2626 2 => array(
'uid' => 3,
'title' =>
'title3',
'testfield' =>
''),
2629 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline;
2630 $this->assertEquals(
'', $this->subject->getData(
'levelfield:-1,testfield'));
2631 $this->assertEquals(
'field2', $this->subject->getData(
'levelfield:-1,testfield,slide'));
2642 0 => array(
'uid' => 1,
'title' =>
'title1',
'testfield' =>
'field1'),
2645 0 => array(
'uid' => 1,
'title' =>
'title1',
'testfield' =>
'field1'),
2646 1 => array(
'uid' => 2,
'title' =>
'title2',
'testfield' =>
'field2'),
2647 2 => array(
'uid' => 3,
'title' =>
'title3',
'testfield' =>
'field3'),
2650 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline1;
2651 $GLOBALS[
'TSFE']->rootLine = $rootline2;
2652 $this->assertEquals(
'field2', $this->subject->getData(
'fullrootline:-1,testfield'));
2663 $defaultFormat =
'd/m Y';
2665 $this->assertEquals(date($format,
$GLOBALS[
'EXEC_TIME']), $this->subject->getData(
'date:' . $format));
2666 $this->assertEquals(date($defaultFormat,
$GLOBALS[
'EXEC_TIME']), $this->subject->getData(
'date'));
2677 $GLOBALS[
'TSFE']->page[
'uid'] = $uid;
2678 $this->assertEquals($uid, $this->subject->getData(
'page:uid'));
2688 $key = $this->getUniqueId(
'someKey');
2689 $value = $this->getUniqueId(
'someValue');
2690 $this->subject->data[$key] = $value;
2691 $this->subject->currentValKey = $key;
2692 $this->assertEquals($value, $this->subject->getData(
'current'));
2702 $dummyRecord = array(
'uid' => 5,
'title' =>
'someTitle');
2704 $GLOBALS[
'TSFE']->sys_page->expects($this->atLeastOnce())->method(
'getRawRecord')->with(
'tt_content',
'106')->will($this->returnValue($dummyRecord));
2705 $this->assertEquals($dummyRecord[
'title'], $this->subject->getData(
'db:tt_content:106:title'));
2715 $key = $this->getUniqueId(
'someKey');
2716 $value = $this->getUniqueId(
'someValue');
2717 $language = $this->getUniqueId(
'someLanguage');
2718 $GLOBALS[
'TSFE']->LL_labels_cache[$language][
'LLL:' . $key] = $value;
2719 $GLOBALS[
'TSFE']->lang = $language;
2721 $this->assertEquals($value, $this->subject->getData(
'lll:' . $key));
2731 $filenameIn = $this->getUniqueId(
'someValue');
2732 $filenameOut = $this->getUniqueId(
'someValue');
2733 $this->templateServiceMock->expects($this->atLeastOnce())->method(
'getFileName')->with($filenameIn)->will($this->returnValue($filenameOut));
2734 $this->assertEquals($filenameOut, $this->subject->getData(
'path:' . $filenameIn));
2744 $recordNumber = rand();
2745 $this->subject->parentRecordNumber = $recordNumber;
2746 $this->assertEquals($recordNumber, $this->subject->getData(
'cobj:parentRecordNumber'));
2757 0 => array(
'uid' => 1,
'title' =>
'title1'),
2758 1 => array(
'uid' => 2,
'title' =>
'title2'),
2759 2 => array(
'uid' => 3,
'title' =>
''),
2761 $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)';
2762 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline;
2764 $result = $this->subject->getData(
'debug:rootLine');
2765 $cleanedResult = strip_tags($result);
2766 $cleanedResult = str_replace(
"\r",
'', $cleanedResult);
2767 $cleanedResult = str_replace(
"\n",
'', $cleanedResult);
2768 $cleanedResult = str_replace(
"\t",
'', $cleanedResult);
2769 $cleanedResult = str_replace(
' ',
'', $cleanedResult);
2771 $this->assertEquals($expectedResult, $cleanedResult);
2782 0 => array(
'uid' => 1,
'title' =>
'title1'),
2783 1 => array(
'uid' => 2,
'title' =>
'title2'),
2784 2 => array(
'uid' => 3,
'title' =>
''),
2786 $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)';
2787 $GLOBALS[
'TSFE']->rootLine = $rootline;
2789 $result = $this->subject->getData(
'debug:fullRootLine');
2790 $cleanedResult = strip_tags($result);
2791 $cleanedResult = str_replace(
"\r",
'', $cleanedResult);
2792 $cleanedResult = str_replace(
"\n",
'', $cleanedResult);
2793 $cleanedResult = str_replace(
"\t",
'', $cleanedResult);
2794 $cleanedResult = str_replace(
' ',
'', $cleanedResult);
2796 $this->assertEquals($expectedResult, $cleanedResult);
2806 $key = $this->getUniqueId(
'someKey');
2807 $value = $this->getUniqueId(
'someValue');
2808 $this->subject->data = array($key => $value);
2810 $expectedResult =
'array(1item)' . $key .
'=>"' . $value .
'"(' . strlen($value) .
'chars)';
2812 $result = $this->subject->getData(
'debug:data');
2813 $cleanedResult = strip_tags($result);
2814 $cleanedResult = str_replace(
"\r",
'', $cleanedResult);
2815 $cleanedResult = str_replace(
"\n",
'', $cleanedResult);
2816 $cleanedResult = str_replace(
"\t",
'', $cleanedResult);
2817 $cleanedResult = str_replace(
' ',
'', $cleanedResult);
2819 $this->assertEquals($expectedResult, $cleanedResult);
2829 $key = $this->getUniqueId(
'someKey');
2830 $value = $this->getUniqueId(
'someValue');
2831 $GLOBALS[
'TSFE']->register = array($key => $value);
2833 $expectedResult =
'array(1item)' . $key .
'=>"' . $value .
'"(' . strlen($value) .
'chars)';
2835 $result = $this->subject->getData(
'debug:register');
2836 $cleanedResult = strip_tags($result);
2837 $cleanedResult = str_replace(
"\r",
'', $cleanedResult);
2838 $cleanedResult = str_replace(
"\n",
'', $cleanedResult);
2839 $cleanedResult = str_replace(
"\t",
'', $cleanedResult);
2840 $cleanedResult = str_replace(
' ',
'', $cleanedResult);
2842 $this->assertEquals($expectedResult, $cleanedResult);
2853 $GLOBALS[
'TSFE']->page = array(
'uid' => $uid);
2855 $expectedResult =
'array(1item)uid=>' . $uid .
'(integer)';
2857 $result = $this->subject->getData(
'debug:page');
2858 $cleanedResult = strip_tags($result);
2859 $cleanedResult = str_replace(
"\r",
'', $cleanedResult);
2860 $cleanedResult = str_replace(
"\n",
'', $cleanedResult);
2861 $cleanedResult = str_replace(
"\t",
'', $cleanedResult);
2862 $cleanedResult = str_replace(
' ',
'', $cleanedResult);
2864 $this->assertEquals($expectedResult, $cleanedResult);
2872 $GLOBALS[
'TYPO3_DB']->expects($this->any())->method(
'exec_SELECTgetSingleRow')->with(
'treelist')->will($this->returnValue(null));
2874 ->expects($this->any())
2875 ->method(
'getRawRecord')
2877 $this->onConsecutiveCalls(
2879 array(
'uid' => 321),
2880 array(
'uid' => 719),
2885 $GLOBALS[
'TSFE']->sys_page->expects($this->any())->method(
'getMountPointInfo')->will($this->returnValue(null));
2887 ->expects($this->any())
2888 ->method(
'exec_SELECTgetRows')
2890 $this->onConsecutiveCalls(
2904 $result = $this->subject->getTreeList(17, 5, 0,
true);
2905 $expectedResult =
'42,719,321';
2906 $this->assertEquals($expectedResult, $result);
2914 $GLOBALS[
'TYPO3_DB']->expects($this->any())->method(
'exec_SELECTgetSingleRow')->with(
'treelist')->will($this->returnValue(null));
2916 ->expects($this->any())
2917 ->method(
'getRawRecord')
2919 $this->onConsecutiveCalls(
2921 array(
'uid' => 321),
2922 array(
'uid' => 719),
2927 $GLOBALS[
'TSFE']->sys_page->expects($this->any())->method(
'getMountPointInfo')->will($this->returnValue(null));
2929 ->expects($this->any())
2930 ->method(
'exec_SELECTgetRows')
2932 $this->onConsecutiveCalls(
2946 $result = $this->subject->getTreeList(-17, 5, 0,
true);
2947 $expectedResult =
'42,719,321,17';
2948 $this->assertEquals($expectedResult, $result);
2956 $aTagParams = $this->subject->getATagParams(array(
'ATagParams' =>
'data-test="testdata"'));
2957 $this->assertEquals(
' data-test="testdata"', $aTagParams);
2965 $GLOBALS[
'TSFE']->ATagParams =
'data-global="dataglobal"';
2966 $aTagParams = $this->subject->getATagParams(array(
'ATagParams' =>
'data-test="testdata"'));
2967 $this->assertEquals(
' data-global="dataglobal" data-test="testdata"', $aTagParams);
2977 $aTagParams = $this->subject->getATagParams(array(
'ATagParams' =>
''));
2978 $this->assertEquals(
'', $aTagParams);
2990 array(
'fooo', array(
'foo' =>
'bar'))
3004 $defaultImgTagTemplate =
'<img src="###SRC###" width="###WIDTH###" height="###HEIGHT###" ###PARAMS### ###ALTPARAMS### ###BORDER######SELFCLOSINGTAGSLASH###>';
3005 $result = $this->subject->getImageTagTemplate($key, $configuration);
3006 $this->assertEquals($result, $defaultImgTagTemplate);
3020 'element' =>
'<img src="###SRC###" srcset="###SOURCES###" ###PARAMS### ###ALTPARAMS### ###FOOBAR######SELFCLOSINGTAGSLASH###>'
3024 '<img src="###SRC###" srcset="###SOURCES###" ###PARAMS### ###ALTPARAMS### ###FOOBAR######SELFCLOSINGTAGSLASH###>'
3041 $result = $this->subject->getImageTagTemplate($key, $configuration);
3042 $this->assertEquals($result, $expectation);
3051 array(null, null, null),
3052 array(
'foo', null, null),
3053 array(
'foo', array(
'sourceCollection.' => 1),
'bar')
3068 $result = $this->subject->getImageSourceCollection($layoutKey, $configuration, $file);
3069 $this->assertSame($result,
'');
3077 public function getImageSourceCollectionRendersDefinedSources()
3080 $cObj = $this->getMock(
3081 \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class,
3082 array(
'stdWrap',
'getImgResource')
3084 $cObj->start(array(),
'tt_content');
3086 $layoutKey =
'test';
3088 $configuration = array(
3089 'layoutKey' =>
'test',
3092 'element' =>
'<img ###SRC### ###SRCCOLLECTION### ###SELFCLOSINGTAGSLASH###>',
3093 'source' =>
'---###SRC###---'
3096 'sourceCollection.' => array(
3103 $file =
'testImageName';
3107 ->expects($this->any())
3109 ->will($this->returnArgument(0));
3113 ->expects($this->exactly(1))
3114 ->method(
'getImgResource')
3115 ->with($this->equalTo(
'testImageName'))
3116 ->will($this->returnValue(array(100, 100, null,
'bar')));
3118 $result = $cObj->getImageSourceCollection($layoutKey, $configuration, $file);
3120 $this->assertEquals(
'---bar---', $result);
3134 $sourceCollectionArray = array(
3137 'srcsetCandidate' =>
'600w',
3138 'mediaQuery' =>
'(max-device-width: 600px)',
3139 'dataKey' =>
'small',
3141 'smallRetina.' => array(
3142 'if.directReturn' => 0,
3144 'pixelDensity' =>
'2',
3145 'srcsetCandidate' =>
'600w 2x',
3146 'mediaQuery' =>
'(max-device-width: 600px) AND (min-resolution: 192dpi)',
3147 'dataKey' =>
'smallRetina',
3154 'layoutKey' =>
'default',
3156 'default.' => array(
3157 'element' =>
'<img src="###SRC###" width="###WIDTH###" height="###HEIGHT###" ###PARAMS### ###ALTPARAMS### ###BORDER######SELFCLOSINGTAGSLASH###>',
3161 'sourceCollection.' => $sourceCollectionArray
3175 public function getImageSourceCollectionRendersDefinedLayoutKeyDefault($layoutKey, $configuration)
3178 $cObj = $this->getMock(
3179 \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class,
3180 array(
'stdWrap',
'getImgResource')
3182 $cObj->start(array(),
'tt_content');
3184 $file =
'testImageName';
3188 ->expects($this->any())
3190 ->will($this->returnArgument(0));
3192 $result = $cObj->getImageSourceCollection($layoutKey, $configuration, $file);
3194 $this->assertEmpty($result);
3208 $sourceCollectionArray = array(
3211 'srcsetCandidate' =>
'600w',
3212 'mediaQuery' =>
'(max-device-width: 600px)',
3213 'dataKey' =>
'small',
3215 'smallRetina.' => array(
3216 'if.directReturn' => 1,
3218 'pixelDensity' =>
'2',
3219 'srcsetCandidate' =>
'600w 2x',
3220 'mediaQuery' =>
'(max-device-width: 600px) AND (min-resolution: 192dpi)',
3221 'dataKey' =>
'smallRetina',
3228 'layoutKey' =>
'srcset',
3231 'element' =>
'<img src="###SRC###" srcset="###SOURCECOLLECTION###" ###PARAMS### ###ALTPARAMS######SELFCLOSINGTAGSLASH###>',
3232 'source' =>
'|*|###SRC### ###SRCSETCANDIDATE###,|*|###SRC### ###SRCSETCANDIDATE###'
3235 'sourceCollection.' => $sourceCollectionArray
3238 'bar-file.jpg 600w,bar-file.jpg 600w 2x',
3243 'layoutKey' =>
'picture',
3245 'picture.' => array(
3246 'element' =>
'<picture>###SOURCECOLLECTION###<img src="###SRC###" ###PARAMS### ###ALTPARAMS######SELFCLOSINGTAGSLASH###></picture>',
3247 'source' =>
'<source src="###SRC###" media="###MEDIAQUERY###"###SELFCLOSINGTAGSLASH###>'
3250 'sourceCollection.' => $sourceCollectionArray,
3253 '<source src="bar-file.jpg" media="(max-device-width: 600px)" /><source src="bar-file.jpg" media="(max-device-width: 600px) AND (min-resolution: 192dpi)" />',
3258 'layoutKey' =>
'picture',
3260 'picture.' => array(
3261 'element' =>
'<picture>###SOURCECOLLECTION###<img src="###SRC###" ###PARAMS### ###ALTPARAMS######SELFCLOSINGTAGSLASH###></picture>',
3262 'source' =>
'<source src="###SRC###" media="###MEDIAQUERY###"###SELFCLOSINGTAGSLASH###>'
3265 'sourceCollection.' => $sourceCollectionArray,
3268 '<source src="bar-file.jpg" media="(max-device-width: 600px)"><source src="bar-file.jpg" media="(max-device-width: 600px) AND (min-resolution: 192dpi)">',
3273 'layoutKey' =>
'data',
3276 'element' =>
'<img src="###SRC###" ###SOURCECOLLECTION### ###PARAMS### ###ALTPARAMS######SELFCLOSINGTAGSLASH###>',
3277 'source' =>
'data-###DATAKEY###="###SRC###"'
3280 'sourceCollection.' => $sourceCollectionArray
3283 'data-small="bar-file.jpg"data-smallRetina="bar-file.jpg"',
3298 public function getImageSourceCollectionRendersDefinedLayoutKeyData($layoutKey, $configuration, $xhtmlDoctype, $expectedHtml)
3301 $cObj = $this->getMock(
3302 \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class,
3303 array(
'stdWrap',
'getImgResource')
3305 $cObj->start(array(),
'tt_content');
3307 $file =
'testImageName';
3309 $GLOBALS[
'TSFE']->xhtmlDoctype = $xhtmlDoctype;
3313 ->expects($this->any())
3315 ->will($this->returnArgument(0));
3319 ->expects($this->exactly(2))
3320 ->method(
'getImgResource')
3321 ->with($this->equalTo(
'testImageName'))
3322 ->will($this->returnValue(array(100, 100, null,
'bar-file.jpg')));
3324 $result = $cObj->getImageSourceCollection($layoutKey, $configuration, $file);
3326 $this->assertEquals($expectedHtml, $result);
3336 $this->subject = $this->getAccessibleMock(
3337 \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class,
3338 array(
'getResourceFactory',
'stdWrap',
'getImgResource')
3340 $this->subject->start(array(),
'tt_content');
3343 $this->subject->expects($this->any())
3345 ->will($this->returnArgument(0));
3347 $this->subject->expects($this->any())
3348 ->method(
'getImgResource')
3349 ->will($this->returnValue(array(100, 100, null,
'bar-file.jpg')));
3351 $resourceFactory = $this->getMock(\TYPO3\CMS\Core\Resource\ResourceFactory::class, array(), array(),
'',
false);
3352 $this->subject->expects($this->any())->method(
'getResourceFactory')->will($this->returnValue($resourceFactory));
3354 $className = $this->getUniqueId(
'tx_coretest_getImageSourceCollectionHookCalled');
3355 $getImageSourceCollectionHookMock = $this->getMock(\TYPO3\CMS\Frontend\ContentObject\ContentObjectOneSourceCollectionHookInterface::class, array(
'getOneSourceCollection'), array(), $className);
3356 $GLOBALS[
'T3_VAR'][
'getUserObj'][$className] = $getImageSourceCollectionHookMock;
3357 $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'getImageSourceCollection'][] = $className;
3359 $getImageSourceCollectionHookMock
3360 ->expects($this->exactly(1))
3361 ->method(
'getOneSourceCollection')
3362 ->will($this->returnCallback(array($this,
'isGetOneSourceCollectionCalledCallback')));
3364 $configuration = array(
3365 'layoutKey' =>
'data',
3368 'element' =>
'<img src="###SRC###" ###SOURCECOLLECTION### ###PARAMS### ###ALTPARAMS######SELFCLOSINGTAGSLASH###>',
3369 'source' =>
'data-###DATAKEY###="###SRC###"'
3372 'sourceCollection.' => array(
3375 'srcsetCandidate' =>
'600w',
3376 'mediaQuery' =>
'(max-device-width: 600px)',
3377 'dataKey' =>
'small',
3382 $result = $this->subject->getImageSourceCollection(
'data', $configuration, $this->getUniqueId(
'testImage-'));
3384 $this->assertSame($result,
'isGetOneSourceCollectionCalledCallback');
3395 list($sourceRenderConfiguration, $sourceConfiguration, $oneSourceCollection, $parent) = func_get_args();
3396 $this->assertTrue(is_array($sourceRenderConfiguration));
3397 $this->assertTrue(is_array($sourceConfiguration));
3398 return 'isGetOneSourceCollectionCalledCallback';
3411 $this->subject->expects($this->any())->method(
'getEnvironmentVariable')->will($this->returnValueMap(
3413 array(
'HTTP_HOST',
'localhost'),
3414 array(
'TYPO3_SITE_PATH',
'/'),
3417 $GLOBALS[
'TSFE']->absRefPrefix =
'';
3419 $this->assertEquals($expected, $this->subject->_call(
'forceAbsoluteUrl',
$url, $configuration));
3428 'Missing forceAbsoluteUrl leaves URL untouched' => array(
3433 'Absolute URL stays unchanged' => array(
3434 'http://example.org/',
3435 'http://example.org/',
3437 'forceAbsoluteUrl' =>
'1'
3440 'Absolute URL stays unchanged 2' => array(
3441 'http://example.org/resource.html',
3442 'http://example.org/resource.html',
3444 'forceAbsoluteUrl' =>
'1'
3447 'Scheme and host w/o ending slash stays unchanged' => array(
3448 'http://example.org',
3449 'http://example.org',
3451 'forceAbsoluteUrl' =>
'1'
3454 'Scheme can be forced' => array(
3455 'typo3://example.org',
3456 'http://example.org',
3458 'forceAbsoluteUrl' =>
'1',
3459 'forceAbsoluteUrl.' => array(
3464 'Relative path old-style' => array(
3465 'http://localhost/fileadmin/dummy.txt',
3466 '/fileadmin/dummy.txt',
3468 'forceAbsoluteUrl' =>
'1',
3471 'Relative path' => array(
3472 'http://localhost/fileadmin/dummy.txt',
3473 'fileadmin/dummy.txt',
3475 'forceAbsoluteUrl' =>
'1',
3478 'Scheme can be forced with pseudo-relative path' => array(
3479 'typo3://localhost/fileadmin/dummy.txt',
3480 '/fileadmin/dummy.txt',
3482 'forceAbsoluteUrl' =>
'1',
3483 'forceAbsoluteUrl.' => array(
3488 'Hostname only is not treated as valid absolute URL' => array(
3489 'http://localhost/example.org',
3492 'forceAbsoluteUrl' =>
'1'
3495 'Scheme and host is added to local file path' => array(
3496 'typo3://localhost/fileadmin/my.pdf',
3499 'forceAbsoluteUrl' =>
'1',
3500 'forceAbsoluteUrl.' => array(
3516 $this->subject->render($contentObjectFixture, array());
3525 Fixtures\GeneralUtilityFixture::setApplicationContext(
new ApplicationContext(
'Production'));
3528 $this->subject->render($contentObjectFixture, array());
3530 Fixtures\GeneralUtilityFixture::setApplicationContext($backupApplicationContext);
3540 $configuration = array(
3541 'exceptionHandler' =>
'1'
3543 $this->subject->render($contentObjectFixture, $configuration);
3553 $this->typoScriptFrontendControllerMock->config[
'config'][
'contentObjectExceptionHandler'] =
'1';
3554 $this->subject->render($contentObjectFixture, array());
3566 $this->typoScriptFrontendControllerMock->config[
'config'][
'contentObjectExceptionHandler'] =
'1';
3567 $configuration = array(
3568 'exceptionHandler' =>
'0'
3570 $this->subject->render($contentObjectFixture, $configuration);
3580 $configuration = array(
3581 'exceptionHandler' =>
'1',
3582 'exceptionHandler.' => array(
3583 'errorMessage' =>
'New message for testing',
3587 $this->assertSame(
'New message for testing', $this->subject->render($contentObjectFixture, $configuration));
3597 $this->typoScriptFrontendControllerMock
3598 ->config[
'config'][
'contentObjectExceptionHandler.'] = array(
3599 'errorMessage' =>
'Global message for testing',
3601 $configuration = array(
3602 'exceptionHandler' =>
'1',
3603 'exceptionHandler.' => array(
3604 'errorMessage' =>
'New message for testing',
3608 $this->assertSame(
'New message for testing', $this->subject->render($contentObjectFixture, $configuration));
3620 $configuration = array(
3621 'exceptionHandler' =>
'1',
3622 'exceptionHandler.' => array(
3623 'ignoreCodes.' => array(
'10.' =>
'1414513947'),
3627 $this->subject->render($contentObjectFixture, $configuration);
3635 $contentObjectFixture = $this->getMock(AbstractContentObject::class, array(), array($this->subject));
3636 $contentObjectFixture->expects($this->once())
3638 ->willReturnCallback(
function () {
3639 throw new \LogicException(
'Exception during rendering', 1414513947);
3641 return $contentObjectFixture;
3650 $this->subject->expects($this->any())->method(
'getEnvironmentVariable')->will($this->returnValueMap(
3652 array(
'HTTP_HOST',
'localhost'),
3653 array(
'TYPO3_SITE_PATH',
'/subfolder/'),
3657 $expected =
'http://localhost/subfolder/fileadmin/my.pdf';
3658 $url =
'fileadmin/my.pdf';
3659 $configuration = array(
3660 'forceAbsoluteUrl' =>
'1'
3663 $this->assertEquals($expected, $this->subject->_call(
'forceAbsoluteUrl',
$url, $configuration));
3673 'override.' => array(
3676 'data' =>
'TSFE:dtdAllowsFrames',
3690 'makelinks.' => array(
3692 'keep' =>
'{$styles.content.links.keep}',
3704 'typolink.' => array(
3705 'parameter.' => array(
3706 'data' =>
'parameters : allParams',
3711 'parseFunc.' => array(
3717 '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',
3719 'sword' =>
'<span class="csc-sword">|</span>',
3721 'nonTypoTagStdWrap.' => array(
3722 'HTMLparser' =>
'1',
3723 'HTMLparser.' => array(
3724 'keepNonMatchedTags' =>
'1',
3725 'htmlSpecialChars' =>
'2',
3738 'parseFunc.' => array(
3739 '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',
3742 'externalBlocks' =>
'article, aside, blockquote, div, dd, dl, footer, header, nav, ol, section, table, ul',
3743 'externalBlocks.' => array(
3744 'article.' => array(
3745 'callRecursive' =>
'1',
3749 'callRecursive' =>
'1',
3752 'blockquote.' => array(
3753 'callRecursive' =>
'1',
3757 'callRecursive' =>
'1',
3761 'callRecursive' =>
'1',
3765 'callRecursive' =>
'1',
3769 'callRecursive' =>
'1',
3773 'callRecursive' =>
'1',
3777 'callRecursive' =>
'1',
3781 'callRecursive' =>
'1',
3784 'section.' => array(
3785 'callRecursive' =>
'1',
3789 'HTMLtableCells' =>
'1',
3790 'HTMLtableCells.' => array(
3791 'addChr10BetweenParagraphs' =>
'1',
3792 'default.' => array(
3793 'stdWrap.' => array(
3794 'parseFunc' =>
'=< lib.parseFunc_RTE',
3795 'parseFunc.' => array(
3796 'nonTypoTagStdWrap.' => array(
3797 'encapsLines.' => array(
3798 'nonWrappedTag' =>
'',
3805 'stdWrap.' => array(
3806 'HTMLparser' =>
'1',
3807 'HTMLparser.' => array(
3808 'keepNonMatchedTags' =>
'1',
3811 'fixAttrib.' => array(
3814 'default' =>
'contenttable',
3815 'list' =>
'contenttable',
3825 'callRecursive' =>
'1',
3830 'makelinks.' => array(
3832 'extTarget.' => array(
3833 'override' =>
'_blank',
3834 'override.' => array(
3837 'data' =>
'TSFE:dtdAllowsFrames',
3845 'nonTypoTagStdWrap.' => array(
3846 'encapsLines.' => array(
3847 'addAttributes.' => array(
3849 'class' =>
'bodytext',
3851 'setOnly' =>
'blank',
3855 'encapsTagList' =>
'p,pre,h1,h2,h3,h4,h5,h6,hr,dt,li',
3856 'innerStdWrap_all.' => array(
3857 'ifBlank' =>
' ',
3859 'nonWrappedTag' =>
'P',
3860 'remapTag.' => array(
3864 'HTMLparser' =>
'1',
3865 'HTMLparser.' => array(
3866 'htmlSpecialChars' =>
'2',
3867 'keepNonMatchedTags' =>
'1',
3870 'sword' =>
'<span class="csc-sword">|</span>',
3875 'parseFunc.' => array(
3878 'typolink.' => array(
3879 'extTarget.' => array(
3881 'override.' => array(
3884 'data' =>
'TSFE:dtdAllowsFrames',
3889 'parameter.' => array(
3890 'data' =>
'parameters : allParams',
3894 'override.' => array(
3897 'data' =>
'TSFE:dtdAllowsFrames',
3915 'Text without tag is wrapped with <p> tag' => array(
3918 '<p class="bodytext">Text without tag</p>',
3920 'Text wrapped with <p> tag remains the same' => array(
3921 '<p class="myclass">Text with <p> tag</p>',
3923 '<p class="myclass">Text with <p> tag</p>',
3925 'Text with absolute external link' => array(
3926 'Text with <link http://example.com/foo/>external link</link>',
3928 '<p class="bodytext">Text with <a href="http://example.com/foo/">external link</a></p>',
3942 $this->assertEquals($expectedResult, $this->subject->stdWrap_parseFunc($value, $configuration));
3951 'Link to url' => array(
3954 'parameter' =>
'http://typo3.org',
3956 '<a href="http://typo3.org">TYPO3</a>',
3958 'Link to url without link text' => array(
3961 'parameter' =>
'http://typo3.org',
3963 '<a href="http://typo3.org">http://typo3.org</a>',
3965 'Link to url with attributes' => array(
3968 'parameter' =>
'http://typo3.org',
3969 'ATagParams' =>
'class="url-class"',
3970 'extTarget' =>
'_blank',
3971 'title' =>
'Open new window',
3973 '<a href="http://typo3.org" title="Open new window" target="_blank" class="url-class">TYPO3</a>',
3975 'Link to url with attributes in parameter' => array(
3978 'parameter' =>
'http://typo3.org _blank url-class "Open new window"',
3980 '<a href="http://typo3.org" title="Open new window" target="_blank" class="url-class">TYPO3</a>',
3982 'Link to url with script tag' => array(
3985 'parameter' =>
'http://typo3.org<script>alert(123)</script>',
3987 '<a href="http://typo3.org<script>alert(123)</script>">http://typo3.org<script>alert(123)</script></a>',
3989 'Link to email address' => array(
3992 'parameter' =>
'foo@bar.org',
3994 '<a href="mailto:foo@bar.org">Email address</a>',
3996 'Link to email address without link text' => array(
3999 'parameter' =>
'foo@bar.org',
4001 '<a href="mailto:foo@bar.org">foo@bar.org</a>',
4003 'Link to email with attributes' => array(
4006 'parameter' =>
'foo@bar.org',
4007 'ATagParams' =>
'class="email-class"',
4008 'title' =>
'Write an email',
4010 '<a href="mailto:foo@bar.org" title="Write an email" class="email-class">Email address</a>',
4012 'Link to email with attributes in parameter' => array(
4015 'parameter' =>
'foo@bar.org - email-class "Write an email"',
4017 '<a href="mailto:foo@bar.org" title="Write an email" class="email-class">Email address</a>',
4031 $templateServiceObjectMock = $this->getMock(\TYPO3\CMS\Core\TypoScript\TemplateService::class, array(
'dummy'));
4032 $templateServiceObjectMock->setup = array(
4037 $typoScriptFrontendControllerMockObject = $this->getMock(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class, array(), array(),
'',
false);
4038 $typoScriptFrontendControllerMockObject->config = array(
4039 'config' => array(),
4040 'mainScript' =>
'index.php',
4042 $typoScriptFrontendControllerMockObject->tmpl = $templateServiceObjectMock;
4043 $GLOBALS[
'TSFE'] = $typoScriptFrontendControllerMockObject;
4044 $this->subject->_set(
'typoScriptFrontendController', $typoScriptFrontendControllerMockObject);
4046 $this->assertEquals($expectedResult, $this->subject->typoLink($linkText, $configuration));
4055 'Link to page' => array(
4062 'title' =>
'Page title',
4064 '<a href="index.php?id=42">My page</a>',
4066 'Link to page without link text' => array(
4073 'title' =>
'Page title',
4075 '<a href="index.php?id=42">Page title</a>',
4077 'Link to page with attributes' => array(
4080 'parameter' =>
'42',
4081 'ATagParams' =>
'class="page-class"',
4082 'target' =>
'_self',
4083 'title' =>
'Link to internal page',
4087 'title' =>
'Page title',
4089 '<a href="index.php?id=42" title="Link to internal page" target="_self" class="page-class">My page</a>',
4091 'Link to page with attributes in parameter' => array(
4094 'parameter' =>
'42 _self page-class "Link to internal page"',
4098 'title' =>
'Page title',
4100 '<a href="index.php?id=42" title="Link to internal page" target="_self" class="page-class">My page</a>',
4102 'Link to page with bold tag in title' => array(
4109 'title' =>
'Page <b>title</b>',
4111 '<a href="index.php?id=42">Page <b>title</b></a>',
4113 'Link to page with script tag in title' => array(
4120 'title' =>
'<script>alert(123)</script>Page title',
4122 '<a href="index.php?id=42"><script>alert(123)</script>Page title</a>',
4137 $pageRepositoryMockObject = $this->getMock(\TYPO3\CMS\Frontend\Page\PageRepository::class, array(
'getPage'));
4138 $pageRepositoryMockObject->expects($this->any())->method(
'getPage')->willReturn($pageArray);
4139 $templateServiceObjectMock = $this->getMock(\TYPO3\CMS\Core\TypoScript\TemplateService::class, array(
'dummy'));
4140 $templateServiceObjectMock->setup = array(
4145 $typoScriptFrontendControllerMockObject = $this->getMock(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class, array(), array(),
'',
false);
4146 $typoScriptFrontendControllerMockObject->config = array(
4147 'config' => array(),
4148 'mainScript' =>
'index.php',
4150 $typoScriptFrontendControllerMockObject->sys_page = $pageRepositoryMockObject;
4151 $typoScriptFrontendControllerMockObject->tmpl = $templateServiceObjectMock;
4152 $GLOBALS[
'TSFE'] = $typoScriptFrontendControllerMockObject;
4153 $this->subject->_set(
'typoScriptFrontendController', $typoScriptFrontendControllerMockObject);
4155 $this->assertEquals($expectedResult, $this->subject->typoLink($linkText, $configuration));
4164 'Link to file' => array(
4167 'parameter' =>
'fileadmin/foo.bar',
4169 '<a href="fileadmin/foo.bar">My file</a>',
4171 'Link to file without link text' => array(
4174 'parameter' =>
'fileadmin/foo.bar',
4176 '<a href="fileadmin/foo.bar">fileadmin/foo.bar</a>',
4178 'Link to file with attributes' => array(
4181 'parameter' =>
'fileadmin/foo.bar',
4182 'ATagParams' =>
'class="file-class"',
4183 'fileTarget' =>
'_blank',
4184 'title' =>
'Title of the file',
4186 '<a href="fileadmin/foo.bar" title="Title of the file" target="_blank" class="file-class">My file</a>',
4188 'Link to file with attributes in parameter' => array(
4191 'parameter' =>
'fileadmin/foo.bar _blank file-class "Title of the file"',
4193 '<a href="fileadmin/foo.bar" title="Title of the file" target="_blank" class="file-class">My file</a>',
4195 'Link to file with script tag in name' => array(
4198 'parameter' =>
'fileadmin/<script>alert(123)</script>',
4200 '<a href="fileadmin/<script>alert(123)</script>">fileadmin/<script>alert(123)</script></a>',
4214 $templateServiceObjectMock = $this->getMock(\TYPO3\CMS\Core\TypoScript\TemplateService::class, array(
'dummy'));
4215 $templateServiceObjectMock->setup = array(
4220 $typoScriptFrontendControllerMockObject = $this->getMock(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class, array(), array(),
'',
false);
4221 $typoScriptFrontendControllerMockObject->config = array(
4222 'config' => array(),
4223 'mainScript' =>
'index.php',
4225 $typoScriptFrontendControllerMockObject->tmpl = $templateServiceObjectMock;
4226 $GLOBALS[
'TSFE'] = $typoScriptFrontendControllerMockObject;
4227 $this->subject->_set(
'typoScriptFrontendController', $typoScriptFrontendControllerMockObject);
4229 $this->assertEquals($expectedResult, $this->subject->typoLink($linkText, $configuration));
4241 $expectedResult = 5;
4242 $amountOfEntries = $this->subject->splitObj(
'1, 2, 3, 4, 5', $conf);
4257 'tt_content' => array(
4266 'uidInList' =>
'42',
4268 'where' =>
'tt_content.cruser_id=5',
4269 'andWhere' =>
'tt_content.crdate>0',
4270 'groupBy' =>
'tt_content.title',
4271 'orderBy' =>
'tt_content.sorting',
4273 'WHERE tt_content.uid=42 AND tt_content.pid IN (43) AND tt_content.cruser_id=5 AND tt_content.crdate>0 GROUP BY tt_content.title ORDER BY tt_content.sorting',
4277 'tt_content' => array(
4279 'delete' =>
'deleted',
4280 'enablecolumns' => array(
4281 'disabled' =>
'hidden',
4282 'starttime' =>
'startdate',
4283 'endtime' =>
'enddate',
4285 'languageField' =>
'sys_language_uid',
4286 'transOrigPointerField' =>
'l18n_parent',
4296 'where' =>
'tt_content.cruser_id=5',
4297 'andWhere' =>
'tt_content.crdate>0',
4298 'groupBy' =>
'tt_content.title',
4299 'orderBy' =>
'tt_content.sorting',
4301 'WHERE tt_content.uid=42 AND tt_content.pid IN (43) AND tt_content.cruser_id=5 AND (tt_content.sys_language_uid = 13) AND tt_content.crdate>0 AND tt_content.deleted=0 AND tt_content.hidden=0 AND tt_content.startdate<=4242 AND (tt_content.enddate=0 OR tt_content.enddate>4242) GROUP BY tt_content.title ORDER BY tt_content.sorting',
4305 'tt_content' => array(
4307 'languageField' =>
'sys_language_uid',
4308 'transOrigPointerField' =>
'l18n_parent',
4318 'where' =>
'tt_content.cruser_id=5',
4319 'languageField' => 0,
4321 'WHERE tt_content.uid=42 AND tt_content.pid IN (43) AND tt_content.cruser_id=5',
4334 public function getWhereReturnCorrectQuery(
$tca, $table, $configuration, $expectedResult)
4337 $GLOBALS[
'SIM_ACCESS_TIME'] =
'4242';
4338 $GLOBALS[
'TSFE']->sys_language_content = 13;
4340 $contentObjectRenderer = $this->getMock(ContentObjectRenderer::class, array(
'checkPidArray'));
4341 $contentObjectRenderer->expects($this->any())->method(
'checkPidArray')->willReturn(explode(
',', $configuration[
'pidInList']));
4342 $this->assertEquals($expectedResult, $contentObjectRenderer->getWhere($table, $configuration));
4354 $fileNameAndPath = PATH_site .
'typo3temp/phpunitJumpUrlTestFile with spaces & amps.txt';
4355 file_put_contents($fileNameAndPath,
'Some test data');
4356 $relativeFileNameAndPath = substr($fileNameAndPath, strlen(PATH_site));
4357 $fileName = substr($fileNameAndPath, strlen(PATH_site .
'typo3temp/'));
4359 $expectedLink = str_replace(
'%2F',
'/', rawurlencode($relativeFileNameAndPath));
4360 $result = $this->subject->filelink($fileName, array(
'path' =>
'typo3temp/'));
4361 $this->assertEquals(
'<a href="' . $expectedLink .
'">' . $fileName .
'</a>', $result);
4363 \TYPO3\CMS\Core\Utility\GeneralUtility::unlink_tempfile($fileNameAndPath);