46 $GLOBALS[
'TYPO3_DB'] = $this->getMock(
'TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array());
47 $this->
template = $this->getMock(
'TYPO3\\CMS\\Core\\TypoScript\\TemplateService', array(
'getFileName',
'linkData'));
48 $this->tsfe = $this->
getAccessibleMock(
'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', array(
'dummy'), array(),
'', FALSE);
50 $this->tsfe->config = array();
51 $this->tsfe->page = array();
52 $sysPageMock = $this->getMock(
'TYPO3\\CMS\\Frontend\\Tests\\Unit\\ContentObject\\Fixtures\\PageRepositoryFixture', array(
'getRawRecord'));
53 $this->tsfe->sys_page = $sysPageMock;
56 $GLOBALS[
'TSFE']->csConvObj = new \TYPO3\CMS\Core\Charset\CharsetConverter();
57 $GLOBALS[
'TSFE']->renderCharset =
'utf-8';
58 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'TYPO3\\CMS\\Core\\Charset\\CharsetConverter_utils'] =
'mbstring';
60 'TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer',
61 array(
'getResourceFactory',
'getEnvironmentVariable')
63 $this->cObj->start(array(),
'tt_content');
77 $GLOBALS[
'TSFE']->renderCharset = $charset;
78 $subject =
$GLOBALS[
'TSFE']->csConvObj->conv($subject,
'iso-8859-1', $charset);
79 $expected =
$GLOBALS[
'TSFE']->csConvObj->conv($expected,
'iso-8859-1', $charset);
90 ->expects($this->atLeastOnce())
91 ->method(
'getFileName')
92 ->with(
'typo3/clear.gif')
93 ->will($this->returnValue(
'typo3/clear.gif'));
95 $resourceFactory = $this->getMock(
'TYPO3\\CMS\\Core\\Resource\\ResourceFactory', array(), array(),
'', FALSE);
96 $this->cObj->expects($this->any())->method(
'getResourceFactory')->will($this->returnValue($resourceFactory));
99 $getImgResourceHookMock = $this->getMock(
'TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectGetImageResourceHookInterface', array(
'getImgResourcePostProcess'), array(), $className);
100 $getImgResourceHookMock
101 ->expects($this->once())
102 ->method(
'getImgResourcePostProcess')
103 ->will($this->returnCallback(array($this,
'isGetImgResourceHookCalledCallback')));
104 $getImgResourceHookObjects = array($getImgResourceHookMock);
105 $this->cObj->_setRef(
'getImgResourceHookObjects', $getImgResourceHookObjects);
106 $this->cObj->getImgResource(
'typo3/clear.gif', array());
116 list($file, $fileArray, $imageResource, $parent) = func_get_args();
117 $this->assertEquals(
'typo3/clear.gif', $file);
118 $this->assertEquals(
'typo3/clear.gif', $imageResource[
'origFile']);
119 $this->assertTrue(is_array($fileArray));
121 return $imageResource;
130 array(
'TEXT',
'Text'),
131 array(
'CASE',
'Case'),
132 array(
'CLEARGIF',
'ClearGif'),
133 array(
'COBJ_ARRAY',
'ContentObjectArray'),
134 array(
'COA',
'ContentObjectArray'),
135 array(
'COA_INT',
'ContentObjectArrayInternal'),
136 array(
'USER',
'User'),
137 array(
'USER_INT',
'UserInternal'),
138 array(
'FILE',
'File'),
139 array(
'FILES',
'Files'),
140 array(
'IMAGE',
'Image'),
141 array(
'IMG_RESOURCE',
'ImageResource'),
142 array(
'IMGTEXT',
'ImageText'),
143 array(
'CONTENT',
'Content'),
144 array(
'RECORDS',
'Records'),
145 array(
'HMENU',
'HierarchicalMenu'),
146 array(
'CTABLE',
'ContentTable'),
147 array(
'OTABLE',
'OffsetTable'),
148 array(
'COLUMNS',
'Columns'),
149 array(
'HRULER',
'HorizontalRuler'),
150 array(
'CASEFUNC',
'Case'),
151 array(
'LOAD_REGISTER',
'LoadRegister'),
152 array(
'RESTORE_REGISTER',
'RestoreRegister'),
153 array(
'FORM',
'Form'),
154 array(
'SEARCHRESULT',
'SearchResult'),
155 array(
'TEMPLATE',
'Template'),
156 array(
'FLUIDTEMPLATE',
'FluidTemplate'),
157 array(
'MULTIMEDIA',
'Multimedia'),
158 array(
'MEDIA',
'Media'),
159 array(
'SWFOBJECT',
'ShockwaveFlashObject'),
160 array(
'FLOWPLAYER',
'FlowPlayer'),
161 array(
'QTOBJECT',
'QuicktimeObject'),
162 array(
'SVG',
'ScalableVectorGraphics'),
163 array(
'EDITPANEL',
'EditPanel'),
174 $fullClassName =
'TYPO3\\CMS\\Frontend\\ContentObject\\' . $className .
'ContentObject';
175 $contentObjectInstance = $this->getMock($fullClassName, array(), array(),
'', FALSE);
177 $this->assertSame($contentObjectInstance, $this->cObj->getContentObject($name));
187 $GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'secureFormmail'] = TRUE;
188 $this->assertNotContains(
'name="recipient', $this->cObj->FORM(array(
'recipient' =>
'foo@bar.com',
'recipient.' => array()), array()));
195 $GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'secureFormmail'] = FALSE;
196 $this->assertContains(
'name="recipient', $this->cObj->FORM(array(
'recipient' =>
'foo@bar.com',
'recipient.' => array()), array()));
206 $this->cObj->expects($this->any())->method(
'getEnvironmentVariable')->with($this->equalTo(
'QUERY_STRING'))->will(
207 $this->returnValue(
'key1=value1&key2=value2&key3[key31]=value31&key3[key32][key321]=value321&key3[key32][key322]=value322')
209 $getQueryArgumentsConfiguration = array();
210 $getQueryArgumentsConfiguration[
'exclude'] = array();
211 $getQueryArgumentsConfiguration[
'exclude'][] =
'key1';
212 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key31]';
213 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key32][key321]';
214 $getQueryArgumentsConfiguration[
'exclude'] = implode(
',', $getQueryArgumentsConfiguration[
'exclude']);
216 $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration);
217 $this->assertEquals($expectedResult, $actualResult);
228 'key31' =>
'value31',
230 'key321' =>
'value321',
231 'key322' =>
'value322' 235 $getQueryArgumentsConfiguration = array();
236 $getQueryArgumentsConfiguration[
'method'] =
'GET';
237 $getQueryArgumentsConfiguration[
'exclude'] = array();
238 $getQueryArgumentsConfiguration[
'exclude'][] =
'key1';
239 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key31]';
240 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key32][key321]';
241 $getQueryArgumentsConfiguration[
'exclude'] = implode(
',', $getQueryArgumentsConfiguration[
'exclude']);
243 $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration);
244 $this->assertEquals($expectedResult, $actualResult);
251 $this->cObj->expects($this->any())->method(
'getEnvironmentVariable')->with($this->equalTo(
'QUERY_STRING'))->will(
252 $this->returnValue(
'key1=value1')
254 $getQueryArgumentsConfiguration = array();
255 $overruleArguments = array(
257 'key1' =>
'value1Overruled',
259 'key2' =>
'value2Overruled' 261 $expectedResult =
'&key1=value1Overruled';
262 $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments);
263 $this->assertEquals($expectedResult, $actualResult);
274 'key31' =>
'value31',
276 'key321' =>
'value321',
277 'key322' =>
'value322' 281 $getQueryArgumentsConfiguration = array();
282 $getQueryArgumentsConfiguration[
'method'] =
'POST';
283 $getQueryArgumentsConfiguration[
'exclude'] = array();
284 $getQueryArgumentsConfiguration[
'exclude'][] =
'key1';
285 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key31]';
286 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key32][key321]';
287 $getQueryArgumentsConfiguration[
'exclude'] = implode(
',', $getQueryArgumentsConfiguration[
'exclude']);
288 $overruleArguments = array(
290 'key2' =>
'value2Overruled',
294 'key321' =>
'value321Overruled',
296 'key322' =>
'value322Overruled',
298 'key323' =>
'value323Overruled' 303 $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments);
304 $this->assertEquals($expectedResult, $actualResult);
311 $this->cObj->expects($this->any())->method(
'getEnvironmentVariable')->with($this->equalTo(
'QUERY_STRING'))->will(
312 $this->returnValue(
'key1=value1&key2=value2&key3[key31]=value31&key3[key32][key321]=value321&key3[key32][key322]=value322')
318 'key31' =>
'value31',
320 'key321' =>
'value321',
321 'key322' =>
'value322' 325 $getQueryArgumentsConfiguration = array();
326 $getQueryArgumentsConfiguration[
'exclude'] = array();
327 $getQueryArgumentsConfiguration[
'exclude'][] =
'key1';
328 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key31]';
329 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key32][key321]';
330 $getQueryArgumentsConfiguration[
'exclude'][] =
'key3[key32][key322]';
331 $getQueryArgumentsConfiguration[
'exclude'] = implode(
',', $getQueryArgumentsConfiguration[
'exclude']);
332 $overruleArguments = array(
334 'key2' =>
'value2Overruled',
338 'key321' =>
'value321Overruled',
340 'key323' =>
'value323Overruled' 344 $expectedResult = $this->
rawUrlEncodeSquareBracketsInUrl(
'&key2=value2Overruled&key3[key32][key321]=value321Overruled&key3[key32][key323]=value323Overruled');
345 $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments, TRUE);
346 $this->assertEquals($expectedResult, $actualResult);
347 $getQueryArgumentsConfiguration[
'method'] =
'POST';
348 $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments, TRUE);
349 $this->assertEquals($expectedResult, $actualResult);
363 'key331' =>
'POST331',
364 'key332' =>
'POST332',
373 'key331' =>
'GET331',
377 $getQueryArgumentsConfiguration = array();
378 $getQueryArgumentsConfiguration[
'method'] =
'POST,GET';
379 $expectedResult = $this->
rawUrlEncodeSquareBracketsInUrl(
'&key1=POST1&key2=GET2&key3[key31]=POST31&key3[key32]=GET32&key3[key33][key331]=GET331&key3[key33][key332]=POST332');
380 $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration);
381 $this->assertEquals($expectedResult, $actualResult);
395 'key331' =>
'GET331',
396 'key332' =>
'GET332',
405 'key331' =>
'POST331',
409 $getQueryArgumentsConfiguration = array();
410 $getQueryArgumentsConfiguration[
'method'] =
'GET,POST';
411 $expectedResult = $this->
rawUrlEncodeSquareBracketsInUrl(
'&key1=GET1&key2=POST2&key3[key31]=GET31&key3[key32]=POST32&key3[key33][key331]=POST331&key3[key33][key332]=GET332');
412 $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration);
413 $this->assertEquals($expectedResult, $actualResult);
423 return str_replace(array(
'[',
']'), array(
'%5B',
'%5D'), $string);
433 $this->assertEquals(
'бла', $this->cObj->crop(
'бла',
'3|...'));
447 $plainText =
'Kasper Sk' . chr(229) .
'rh' . chr(248) .
'j implemented the original version of the crop function.';
448 $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.';
449 $textWithEntities =
'Kasper Skårhøj implemented the; original ' .
'version of the crop function.';
450 $charsets = array(
'iso-8859-1',
'utf-8',
'ascii',
'big5');
452 foreach ($charsets as $charset) {
453 $data = array_merge($data, array(
454 $charset .
' plain text; 11|...' => array(
457 'Kasper Sk' . chr(229) .
'r...',
460 $charset .
' plain text; -58|...' => array(
463 '...h' . chr(248) .
'j implemented the original version of the crop function.',
466 $charset .
' plain text; 4|...|1' => array(
472 $charset .
' plain text; 20|...|1' => array(
475 'Kasper Sk' . chr(229) .
'rh' . chr(248) .
'j...',
478 $charset .
' plain text; -5|...|1' => array(
484 $charset .
' plain text; -49|...|1' => array(
487 '...the original version of the crop function.',
490 $charset .
' text with markup; 11|...' => array(
493 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) .
'r...</a></strong>',
496 $charset .
' text with markup; 13|...' => array(
499 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) .
'rh' . chr(248) .
'...</a></strong>',
502 $charset .
' text with markup; 14|...' => array(
505 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) .
'rh' . chr(248) .
'j</a>...</strong>',
508 $charset .
' text with markup; 15|...' => array(
511 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) .
'rh' . chr(248) .
'j</a> ...</strong>',
514 $charset .
' text with markup; 29|...' => array(
517 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) .
'rh' . chr(248) .
'j</a> implemented</strong> th...',
520 $charset .
' text with markup; -58|...' => array(
523 '<strong><a href="mailto:kasper@typo3.org">...h' . chr(248) .
'j</a> implemented</strong> the original version of the crop function.',
526 $charset .
' text with markup 4|...|1' => array(
529 '<strong><a href="mailto:kasper@typo3.org">Kasp...</a></strong>',
532 $charset .
' text with markup; 11|...|1' => array(
535 '<strong><a href="mailto:kasper@typo3.org">Kasper...</a></strong>',
538 $charset .
' text with markup; 13|...|1' => array(
541 '<strong><a href="mailto:kasper@typo3.org">Kasper...</a></strong>',
544 $charset .
' text with markup; 14|...|1' => array(
547 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) .
'rh' . chr(248) .
'j</a>...</strong>',
550 $charset .
' text with markup; 15|...|1' => array(
553 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) .
'rh' . chr(248) .
'j</a>...</strong>',
556 $charset .
' text with markup; 29|...|1' => array(
559 '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) .
'rh' . chr(248) .
'j</a> implemented</strong>...',
562 $charset .
' text with markup; -66|...|1' => array(
565 '<strong><a href="mailto:kasper@typo3.org">...Sk' . chr(229) .
'rh' . chr(248) .
'j</a> implemented</strong> the original version of the crop function.',
568 $charset .
' text with entities 9|...' => array(
574 $charset .
' text with entities 10|...' => array(
577 'Kasper Skå...',
580 $charset .
' text with entities 11|...' => array(
583 'Kasper Skår...',
586 $charset .
' text with entities 13|...' => array(
589 'Kasper Skårhø...',
592 $charset .
' text with entities 14|...' => array(
595 'Kasper Skårhøj...',
598 $charset .
' text with entities 15|...' => array(
601 'Kasper Skårhøj ...',
604 $charset .
' text with entities 16|...' => array(
607 'Kasper Skårhøj i...',
610 $charset .
' text with entities -57|...' => array(
613 '...j implemented the; original version of the crop function.',
616 $charset .
' text with entities -58|...' => array(
619 '...øj implemented the; original version of the crop function.',
622 $charset .
' text with entities -59|...' => array(
625 '...høj implemented the; original version of the crop function.',
628 $charset .
' text with entities 4|...|1' => array(
634 $charset .
' text with entities 9|...|1' => array(
640 $charset .
' text with entities 10|...|1' => array(
646 $charset .
' text with entities 11|...|1' => array(
652 $charset .
' text with entities 13|...|1' => array(
658 $charset .
' text with entities 14|...|1' => array(
661 'Kasper Skårhøj...',
664 $charset .
' text with entities 15|...|1' => array(
667 'Kasper Skårhøj...',
670 $charset .
' text with entities 16|...|1' => array(
673 'Kasper Skårhøj...',
676 $charset .
' text with entities -57|...|1' => array(
679 '...implemented the; original version of the crop function.',
682 $charset .
' text with entities -58|...|1' => array(
685 '...implemented the; original version of the crop function.',
688 $charset .
' text with entities -59|...|1' => array(
691 '...implemented the; original version of the crop function.',
694 $charset .
' text with dash in html-element 28|...|1' => array(
696 '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',
697 'Some text with a link to <link email.address@example.org - mail "Open email window">my...</link>',
700 $charset .
' html elements with dashes in attributes' => array(
702 '<em data-foo="x">foobar</em>foobaz',
703 '<em data-foo="x">foobar</em>foo',
706 $charset .
' html elements with iframe embedded 24|...|1' => array(
708 'Text with iframe <iframe src="//what.ever/"></iframe> and text after it',
709 'Text with iframe <iframe src="//what.ever/"></iframe> and...',
712 $charset .
' html elements with script tag embedded 24|...|1' => array(
714 'Text with script <script>alert(\'foo\');</script> and text after it',
715 'Text with script <script>alert(\'foo\');</script> and...',
735 $this->assertEquals($expected, $this->cObj->cropHTML($subject, $settings),
'cropHTML failed with settings: "' . $settings .
'" and charset "' . $charset .
'"');
745 $GLOBALS[
'TSFE']->renderCharset =
'iso-8859-1';
748 <h1>Blog Example</h1> 750 <div class="csc-header csc-header-n1"> 751 <h2 class="csc-firstHeader">Welcome to Blog #1</h2> 754 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>. 756 <div class="tx-blogexample-list-container"> 758 Below are the most recent posts: 761 <li data-element="someId"> 763 <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> 766 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut... 769 Published on 26.08.2009 by Jochen Rau 772 Tags: [MVC] [Domain Driven Design] <br> 773 <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> 774 <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> 779 <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> 787 $result = $this->cObj->cropHTML($subject,
'300');
789 <h1>Blog Example</h1> 791 <div class="csc-header csc-header-n1"> 792 <h2 class="csc-firstHeader">Welcome to Blog #1</h2> 795 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>. 797 <div class="tx-blogexample-list-container"> 799 Below are the most recent posts: 802 <li data-element="someId"> 804 <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 Pos</a></h3></li></ul></div>';
805 $this->assertEquals($expected,
$result);
806 $result = $this->cObj->cropHTML($subject,
'-100');
807 $expected =
'<div class="tx-blogexample-list-container"><ul><li data-element="someId"><p>Design] <br> 808 <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> 809 <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> 814 <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> 822 $this->assertEquals($expected,
$result);
830 'rounding off without any configuration' => array(
835 'rounding up without any configuration' => array(
840 'regular rounding (off) to two decimals' => array(
847 'regular rounding (up) to two decimals' => array(
854 'rounding up to integer with type ceil' => array(
857 'roundType' =>
'ceil' 861 'rounding down to integer with type floor' => array(
864 'roundType' =>
'floor' 877 $subject =
"Lorem ipsum dolor sit amet,\nconsetetur sadipscing elitr,\nsed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam";
878 $expected =
"Lorem ipsum dolor sit amet,\nconsetetur sadipscing elitr,\nsed diam nonumy eirmod tempor invidunt ut labore et dolore magna";
879 $result = $this->cObj->cropHTML($subject,
'121');
880 $this->assertEquals($expected,
$result);
897 $result = $this->cObj->stdWrap_round($float, $conf);
898 $this->assertEquals($expected,
$result);
906 'pad string with default settings and length 10' => array(
913 'pad string with padWith -= and type left and length 10' => array(
922 'pad string with padWith _ and type both and length 10' => array(
931 'pad string with padWith 0 and type both and length 10' => array(
940 'pad string with padWith ___ and type both and length 6' => array(
949 'pad string with padWith _ and type both and length 12, using stdWrap for length' => array(
961 'pad string with padWith _ and type both and length 12, using stdWrap for padWidth' => array(
973 'pad string with padWith _ and type both and length 12, using stdWrap for type' => array(
981 'substring' =>
'2,1',
1004 $result = $this->cObj->stdWrap_strPad($content, $conf);
1005 $this->assertEquals($expected,
$result);
1016 'testing md5' => array(
1021 'bacb98acf97e0b6112b1d1b650b84971' 1023 'testing sha1' => array(
1028 '063b3d108bed9f88fa618c6046de0dccadcf3158' 1030 'testing non-existing hashing algorithm' => array(
1033 'hash' =>
'non-existing' 1037 'testing stdWrap capability' => array(
1041 'cObject' =>
'TEXT',
1042 'cObject.' => array(
1047 'bacb98acf97e0b6112b1d1b650b84971' 1064 $result = $this->cObj->stdWrap_hash($text, $conf);
1065 $this->assertEquals($expected,
$result);
1076 'testing decimals' => array(
1083 'testing decimals with input as string' => array(
1090 'testing dec_point' => array(
1098 'testing thousands_sep' => array(
1102 'thousands_sep.' => array(
1108 'testing mixture' => array(
1112 'dec_point.' => array(
1115 'thousands_sep.' => array(
1132 $result = $this->cObj->numberFormat($float, $formatConf);
1133 $this->assertEquals($expected,
$result);
1144 'multiple replacements, including regex' => array(
1145 'There_is_a_cat,_a_dog_and_a_tiger_in_da_hood!_Yeah!',
1147 'replacement.' => array(
1149 'search' =>
'in da hood',
1150 'replace' =>
'around the block' 1154 'replace.' => array(
'char' =>
'32')
1157 'search' =>
'#a (Cat|Dog|Tiger)#i',
1158 'replace' =>
'an animal',
1163 'There is an animal, an animal and an animal around the block! Yeah!' 1165 'replacement with optionSplit, normal pattern' => array(
1166 'There_is_a_cat,_a_dog_and_a_tiger_in_da_hood!_Yeah!',
1168 'replacement.' => array(
1171 'replace' =>
'1 || 2 || 3',
1172 'useOptionSplitReplace' =>
'1' 1176 'There1is2a3cat,3a3dog3and3a3tiger3in3da3hood!3Yeah!' 1178 'replacement with optionSplit, using regex' => array(
1179 'There is a cat, a dog and a tiger in da hood! Yeah!',
1181 'replacement.' => array(
1183 'search' =>
'#(a) (Cat|Dog|Tiger)#i',
1184 'replace' =>
'${1} tiny ${2} || ${1} midsized ${2} || ${1} big ${2}',
1185 'useOptionSplitReplace' =>
'1',
1190 'There is a tiny cat, a midsized dog and a big tiger in da hood! Yeah!' 1203 $result = $this->cObj->stdWrap_replacement($input, $conf);
1204 $this->assertEquals($expected,
$result);
1215 'testing empty conf' => array(
1222 'testing #17284: adding uid/pid for workspaces' => array(
1225 'selectFields' =>
'header,bodytext' 1228 'SELECT' =>
'header,bodytext, tt_content.uid as uid, tt_content.pid as pid, tt_content.t3ver_state as t3ver_state' 1231 'testing #17284: no need to add' => array(
1234 'selectFields' =>
'tt_content.*' 1237 'SELECT' =>
'tt_content.*' 1240 'testing #17284: no need to add #2' => array(
1243 'selectFields' =>
'*' 1249 'testing #29783: joined tables, prefix tablename' => array(
1252 'selectFields' =>
'tt_content.header,be_users.username',
1253 'join' =>
'be_users ON tt_content.cruser_id = be_users.uid' 1256 'SELECT' =>
'tt_content.header,be_users.username, tt_content.uid as uid, tt_content.pid as pid, tt_content.t3ver_state as t3ver_state' 1259 'testing #34152: single count(*), add nothing' => array(
1262 'selectFields' =>
'count(*)' 1265 'SELECT' =>
'count(*)' 1268 'testing #34152: single max(crdate), add nothing' => array(
1271 'selectFields' =>
'max(crdate)' 1274 'SELECT' =>
'max(crdate)' 1277 'testing #34152: single min(crdate), add nothing' => array(
1280 'selectFields' =>
'min(crdate)' 1283 'SELECT' =>
'min(crdate)' 1286 'testing #34152: single sum(is_siteroot), add nothing' => array(
1289 'selectFields' =>
'sum(is_siteroot)' 1292 'SELECT' =>
'sum(is_siteroot)' 1295 'testing #34152: single avg(crdate), add nothing' => array(
1298 'selectFields' =>
'avg(crdate)' 1301 'SELECT' =>
'avg(crdate)' 1318 'enablecolumns' => array(
1319 'disabled' =>
'hidden' 1323 'tt_content' => array(
1325 'enablecolumns' => array(
1326 'disabled' =>
'hidden' 1332 $result = $this->cObj->getQuery($table, $conf, TRUE);
1333 foreach ($expected as $field => $value) {
1334 $this->assertEquals($value,
$result[$field]);
1345 'enablecolumns' => array(
1346 'disabled' =>
'hidden' 1350 'tt_content' => array(
1352 'enablecolumns' => array(
1353 'disabled' =>
'hidden' 1358 $this->cObj = $this->
getAccessibleMock(
'\\TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer', array(
'getTreeList'));
1359 $this->cObj->start(array(),
'tt_content');
1361 'recursive' =>
'15',
1362 'pidInList' =>
'16, -35' 1364 $this->cObj->expects($this->at(0))
1365 ->method(
'getTreeList')
1367 ->will($this->returnValue(
'15,16'));
1368 $this->cObj->expects($this->at(1))
1369 ->method(
'getTreeList')
1371 ->will($this->returnValue(
'15,35'));
1372 $this->cObj->getQuery(
'tt_content', $conf, TRUE);
1382 'enablecolumns' => array(
1383 'disabled' =>
'hidden' 1387 'tt_content' => array(
1389 'enablecolumns' => array(
1390 'disabled' =>
'hidden' 1395 $this->cObj = $this->
getAccessibleMock(
'\\TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer', array(
'getTreeList'));
1397 $this->cObj->start(array(),
'tt_content');
1399 'pidInList' =>
'this',
1402 $this->cObj->expects($this->once())
1403 ->method(
'getTreeList')
1405 ->will($this->returnValue(
'27'));
1406 $this->cObj->getQuery(
'tt_content', $conf, TRUE);
1417 'given timestamp' => array(
1420 'strftime' =>
'%d-%m-%Y',
1423 'empty string' => array(
1426 'strftime' =>
'%d-%m-%Y',
1429 'testing null' => array(
1432 'strftime' =>
'%d-%m-%Y',
1445 $GLOBALS[
'EXEC_TIME'] = 1346500800;
1448 $timezoneBackup = date_default_timezone_get();
1449 date_default_timezone_set(
'UTC');
1451 $result = $this->cObj->stdWrap_strftime($content, $conf);
1454 date_default_timezone_set($timezoneBackup);
1456 $this->assertEquals(
'01-09-2012',
$result);
1467 $result = $this->cObj->stdWrap_ifNull($content, $configuration);
1468 $this->assertEquals($expected,
$result);
1478 'null value' => array(
1485 'zero value' => array(
1503 $result = $this->cObj->stdWrap_noTrimWrap($content, $configuration);
1504 $this->assertEquals($expected,
$result);
1514 'No char given' => array(
1517 'noTrimWrap' =>
'| left | right |',
1519 ' left middle right ' 1521 'Zero char given' => array(
1524 'noTrimWrap' =>
'0 left 0 right 0',
1525 'noTrimWrap.' => array(
'splitChar' =>
'0'),
1528 ' left middle right ' 1530 'Default char given' => array(
1533 'noTrimWrap' =>
'| left | right |',
1534 'noTrimWrap.' => array(
'splitChar' =>
'|'),
1536 ' left middle right ' 1538 'Split char is a' => array(
1541 'noTrimWrap' =>
'a left a right a',
1542 'noTrimWrap.' => array(
'splitChar' =>
'a'),
1544 ' left middle right ' 1546 'Split char is multi-char (ab)' => array(
1549 'noTrimWrap' =>
'ab left ab right ab',
1550 'noTrimWrap.' => array(
'splitChar' =>
'ab'),
1552 ' left middle right ' 1554 'Split char accepts stdWrap' => array(
1557 'noTrimWrap' =>
'abc left abc right abc',
1558 'noTrimWrap.' => array(
1560 'splitChar.' => array(
'wrap' =>
'a|c'),
1563 ' left middle right ' 1575 $this->cObj->stdWrap_addPageCacheTags(
'', $configuration);
1576 $this->assertEquals($expectedTags, $this->tsfe->_get(
'pageCacheTags'));
1586 array(
'addPageCacheTags' =>
''),
1588 'Two expectedTags' => array(
1589 array(
'tag1',
'tag2'),
1590 array(
'addPageCacheTags' =>
'tag1,tag2'),
1592 'Two expectedTags plus one with stdWrap' => array(
1593 array(
'tag1',
'tag2',
'tag3'),
1595 'addPageCacheTags' =>
'tag1,tag2',
1596 'addPageCacheTags.' => array(
'wrap' =>
'|,tag3')
1610 'double quote in string' => array(
1613 '\'double\u0020quote\u0022\
'' 1615 'backslash in string' => array(
1618 '\'backslash\u0020\u005C\
'' 1620 'exclamation mark' => array(
1623 '\'exclamation\u0021\
'' 1625 'whitespace tab, newline and carriage return' => array(
1626 "white\tspace\ns\r",
1628 '\'white\u0009space\u000As\u000D\
'' 1630 'single quote in string' => array(
1633 '\'single\u0020quote\u0020\u0027\
'' 1638 '\'\u003Ctag\u003E\
'' 1640 'ampersand in string' => array(
1643 '\'amper\u0026sand\
'' 1655 $result = $this->cObj->stdWrap_encodeForJavaScriptValue($input, $conf);
1656 $this->assertEquals($expected,
$result);
1669 'Value in get-data' => array(
'onlyInGet',
'GetValue'),
1670 'Value in post-data' => array(
'onlyInPost',
'PostValue'),
1671 'Value in post-data overriding get-data' => array(
'inGetAndPost',
'ValueInPost'),
1683 'onlyInGet' =>
'GetValue',
1684 'inGetAndPost' =>
'ValueInGet',
1687 'onlyInPost' =>
'PostValue',
1688 'inGetAndPost' =>
'ValueInPost',
1690 $this->assertEquals($expectedValue, $this->cObj->getData(
'gp:' . $key));
1699 $this->assertEquals(
$GLOBALS[
'TSFE']->renderCharset, $this->cObj->getData(
'tsfe:renderCharset'));
1710 putenv($envName .
'=' . $value);
1711 $this->assertEquals($value, $this->cObj->getData(
'getenv:' . $envName));
1720 $this->cObj->expects($this->once())->method(
'getEnvironmentVariable')
1721 ->with($this->equalTo(
'SCRIPT_FILENAME'))->will($this->returnValue(
'dummyPath'));
1722 $this->assertEquals(
'dummyPath', $this->cObj->getData(
'getindpenv:SCRIPT_FILENAME'));
1732 $value =
'someValue';
1733 $field = array($key => $value);
1735 $this->assertEquals($value, $this->cObj->getData(
'field:' . $key, $field));
1745 $file = $this->getMock(
'TYPO3\\CMS\\Core\\Resource\File', array(), array(),
'', FALSE);
1746 $file->expects($this->once())->method(
'getUid')->will($this->returnValue(
$uid));
1747 $this->cObj->setCurrentFile($file);
1748 $this->assertEquals(
$uid, $this->cObj->getData(
'file:current:uid'));
1759 $this->cObj->parameters[$key] = $value;
1761 $this->assertEquals($value, $this->cObj->getData(
'parameters:' . $key));
1772 $GLOBALS[
'TSFE']->register[$key] = $value;
1774 $this->assertEquals($value, $this->cObj->getData(
'register:' . $key));
1784 0 => array(
'uid' => 1,
'title' =>
'title1'),
1785 1 => array(
'uid' => 2,
'title' =>
'title2'),
1786 2 => array(
'uid' => 3,
'title' =>
'title3'),
1789 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline;
1790 $this->assertEquals(2, $this->cObj->getData(
'level'));
1799 $this->assertEquals(
$GLOBALS[
'TSFE']->renderCharset, $this->cObj->getData(
'global:TSFE|renderCharset'));
1809 0 => array(
'uid' => 1,
'title' =>
'title1'),
1810 1 => array(
'uid' => 2,
'title' =>
'title2'),
1811 2 => array(
'uid' => 3,
'title' =>
''),
1814 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline;
1815 $this->assertEquals(
'', $this->cObj->getData(
'leveltitle:-1'));
1817 $this->assertEquals(
'title2', $this->cObj->getData(
'leveltitle:-1,slide'));
1827 0 => array(
'uid' => 1,
'title' =>
'title1',
'media' =>
'media1'),
1828 1 => array(
'uid' => 2,
'title' =>
'title2',
'media' =>
'media2'),
1829 2 => array(
'uid' => 3,
'title' =>
'title3',
'media' =>
''),
1832 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline;
1833 $this->assertEquals(
'', $this->cObj->getData(
'levelmedia:-1'));
1835 $this->assertEquals(
'media2', $this->cObj->getData(
'levelmedia:-1,slide'));
1845 0 => array(
'uid' => 1,
'title' =>
'title1'),
1846 1 => array(
'uid' => 2,
'title' =>
'title2'),
1847 2 => array(
'uid' => 3,
'title' =>
'title3'),
1850 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline;
1851 $this->assertEquals(3, $this->cObj->getData(
'leveluid:-1'));
1853 $this->assertEquals(3, $this->cObj->getData(
'leveluid:-1,slide'));
1863 0 => array(
'uid' => 1,
'title' =>
'title1',
'testfield' =>
'field1'),
1864 1 => array(
'uid' => 2,
'title' =>
'title2',
'testfield' =>
'field2'),
1865 2 => array(
'uid' => 3,
'title' =>
'title3',
'testfield' =>
''),
1868 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline;
1869 $this->assertEquals(
'', $this->cObj->getData(
'levelfield:-1,testfield'));
1870 $this->assertEquals(
'field2', $this->cObj->getData(
'levelfield:-1,testfield,slide'));
1880 0 => array(
'uid' => 1,
'title' =>
'title1',
'testfield' =>
'field1'),
1883 0 => array(
'uid' => 1,
'title' =>
'title1',
'testfield' =>
'field1'),
1884 1 => array(
'uid' => 2,
'title' =>
'title2',
'testfield' =>
'field2'),
1885 2 => array(
'uid' => 3,
'title' =>
'title3',
'testfield' =>
'field3'),
1888 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline1;
1889 $GLOBALS[
'TSFE']->rootLine = $rootline2;
1890 $this->assertEquals(
'field2', $this->cObj->getData(
'fullrootline:-1,testfield'));
1900 $defaultFormat =
'd/m Y';
1902 $this->assertEquals(date($format,
$GLOBALS[
'EXEC_TIME']), $this->cObj->getData(
'date:' . $format));
1903 $this->assertEquals(date($defaultFormat,
$GLOBALS[
'EXEC_TIME']), $this->cObj->getData(
'date'));
1914 $this->assertEquals(
$uid, $this->cObj->getData(
'page:uid'));
1925 $this->cObj->data[$key] = $value;
1926 $this->cObj->currentValKey = $key;
1927 $this->assertEquals($value, $this->cObj->getData(
'current'));
1936 $dummyRecord = array(
'uid' => 5,
'title' =>
'someTitle');
1938 $GLOBALS[
'TSFE']->sys_page->expects($this->atLeastOnce())->method(
'getRawRecord')->with(
'tt_content',
'106')->will($this->returnValue($dummyRecord));
1939 $this->assertEquals($dummyRecord[
'title'], $this->cObj->getData(
'db:tt_content:106:title'));
1951 $GLOBALS[
'TSFE']->LL_labels_cache[$language][
'LLL:' . $key] = $value;
1952 $GLOBALS[
'TSFE']->lang = $language;
1954 $this->assertEquals($value, $this->cObj->getData(
'lll:' . $key));
1965 $this->
template->expects($this->atLeastOnce())->method(
'getFileName')->with($filenameIn)->will($this->returnValue($filenameOut));
1966 $this->assertEquals($filenameOut, $this->cObj->getData(
'path:' . $filenameIn));
1975 $recordNumber = rand();
1976 $this->cObj->parentRecordNumber = $recordNumber;
1977 $this->assertEquals($recordNumber, $this->cObj->getData(
'cobj:parentRecordNumber'));
1987 0 => array(
'uid' => 1,
'title' =>
'title1'),
1988 1 => array(
'uid' => 2,
'title' =>
'title2'),
1989 2 => array(
'uid' => 3,
'title' =>
''),
1991 $expectedResult =
'0uid1titletitle11uid2titletitle22uid3title';
1992 $GLOBALS[
'TSFE']->tmpl->rootLine = $rootline;
1994 $result = $this->cObj->getData(
'debug:rootLine');
1995 $cleanedResult = strip_tags(
$result);
1996 $cleanedResult = str_replace(
"\r",
'', $cleanedResult);
1997 $cleanedResult = str_replace(
"\n",
'', $cleanedResult);
1998 $cleanedResult = str_replace(
"\t",
'', $cleanedResult);
1999 $cleanedResult = str_replace(
' ',
'', $cleanedResult);
2001 $this->assertEquals($expectedResult, $cleanedResult);
2011 0 => array(
'uid' => 1,
'title' =>
'title1'),
2012 1 => array(
'uid' => 2,
'title' =>
'title2'),
2013 2 => array(
'uid' => 3,
'title' =>
''),
2015 $expectedResult =
'0uid1titletitle11uid2titletitle22uid3title';
2016 $GLOBALS[
'TSFE']->rootLine = $rootline;
2018 $result = $this->cObj->getData(
'debug:fullRootLine');
2019 $cleanedResult = strip_tags(
$result);
2020 $cleanedResult = str_replace(
"\r",
'', $cleanedResult);
2021 $cleanedResult = str_replace(
"\n",
'', $cleanedResult);
2022 $cleanedResult = str_replace(
"\t",
'', $cleanedResult);
2023 $cleanedResult = str_replace(
' ',
'', $cleanedResult);
2025 $this->assertEquals($expectedResult, $cleanedResult);
2036 $this->cObj->data = array($key => $value);
2038 $expectedResult = $key . $value;
2040 $result = $this->cObj->getData(
'debug:data');
2041 $cleanedResult = strip_tags(
$result);
2042 $cleanedResult = str_replace(
"\r",
'', $cleanedResult);
2043 $cleanedResult = str_replace(
"\n",
'', $cleanedResult);
2044 $cleanedResult = str_replace(
"\t",
'', $cleanedResult);
2045 $cleanedResult = str_replace(
' ',
'', $cleanedResult);
2047 $this->assertEquals($expectedResult, $cleanedResult);
2058 $GLOBALS[
'TSFE']->register = array($key => $value);
2060 $expectedResult = $key . $value;
2062 $result = $this->cObj->getData(
'debug:register');
2063 $cleanedResult = strip_tags(
$result);
2064 $cleanedResult = str_replace(
"\r",
'', $cleanedResult);
2065 $cleanedResult = str_replace(
"\n",
'', $cleanedResult);
2066 $cleanedResult = str_replace(
"\t",
'', $cleanedResult);
2067 $cleanedResult = str_replace(
' ',
'', $cleanedResult);
2069 $this->assertEquals($expectedResult, $cleanedResult);
2081 $expectedResult =
'uid' .
$uid;
2083 $result = $this->cObj->getData(
'debug:page');
2084 $cleanedResult = strip_tags(
$result);
2085 $cleanedResult = str_replace(
"\r",
'', $cleanedResult);
2086 $cleanedResult = str_replace(
"\n",
'', $cleanedResult);
2087 $cleanedResult = str_replace(
"\t",
'', $cleanedResult);
2088 $cleanedResult = str_replace(
' ',
'', $cleanedResult);
2090 $this->assertEquals($expectedResult, $cleanedResult);
2097 $GLOBALS[
'TYPO3_DB']->expects($this->any())->method(
'exec_SELECTgetSingleRow')->with(
'treelist')->will($this->returnValue(NULL));
2099 ->expects($this->any())
2100 ->method(
'getRawRecord')
2102 $this->onConsecutiveCalls(
2104 array(
'uid' => 321),
2105 array(
'uid' => 719),
2110 $GLOBALS[
'TSFE']->sys_page->expects($this->any())->method(
'getMountPointInfo')->will($this->returnValue(NULL));
2112 ->expects($this->any())
2113 ->method(
'exec_SELECTgetRows')
2115 $this->onConsecutiveCalls(
2129 $result = $this->cObj->getTreeList(17, 5, 0, TRUE);
2130 $expectedResult =
'42,719,321';
2131 $this->assertEquals($expectedResult,
$result);
2138 $GLOBALS[
'TYPO3_DB']->expects($this->any())->method(
'exec_SELECTgetSingleRow')->with(
'treelist')->will($this->returnValue(NULL));
2140 ->expects($this->any())
2141 ->method(
'getRawRecord')
2143 $this->onConsecutiveCalls(
2145 array(
'uid' => 321),
2146 array(
'uid' => 719),
2151 $GLOBALS[
'TSFE']->sys_page->expects($this->any())->method(
'getMountPointInfo')->will($this->returnValue(NULL));
2153 ->expects($this->any())
2154 ->method(
'exec_SELECTgetRows')
2156 $this->onConsecutiveCalls(
2170 $result = $this->cObj->getTreeList(-17, 5, 0, TRUE);
2171 $expectedResult =
'42,719,321,17';
2172 $this->assertEquals($expectedResult,
$result);
2179 $aTagParams = $this->cObj->getATagParams(array(
'ATagParams' =>
'data-test="testdata"'));
2180 $this->assertEquals(
' data-test="testdata"', $aTagParams );
2187 $GLOBALS[
'TSFE']->ATagParams =
'data-global="dataglobal"';
2188 $aTagParams = $this->cObj->getATagParams(array(
'ATagParams' =>
'data-test="testdata"'));
2189 $this->assertEquals(
' data-global="dataglobal" data-test="testdata"', $aTagParams );
2198 $aTagParams = $this->cObj->getATagParams(array(
'ATagParams' =>
''));
2199 $this->assertEquals(
'', $aTagParams);
2210 array(
'fooo', array(
'foo' =>
'bar'))
2223 $defaultImgTagTemplate =
'<img src="###SRC###" width="###WIDTH###" height="###HEIGHT###" ###PARAMS### ###ALTPARAMS### ###BORDER######SELFCLOSINGTAGSLASH###>';
2224 $result = $this->cObj->getImageTagTemplate($key, $configuration);
2225 $this->assertEquals(
$result, $defaultImgTagTemplate);
2238 'element' =>
'<img src="###SRC###" srcset="###SOURCES###" ###PARAMS### ###ALTPARAMS### ###FOOBAR######SELFCLOSINGTAGSLASH###>' 2242 '<img src="###SRC###" srcset="###SOURCES###" ###PARAMS### ###ALTPARAMS### ###FOOBAR######SELFCLOSINGTAGSLASH###>' 2258 $result = $this->cObj->getImageTagTemplate($key, $configuration);
2259 $this->assertEquals(
$result, $expectation);
2267 array(NULL, NULL, NULL),
2268 array(
'foo', NULL, NULL),
2269 array(
'foo', array(
'sourceCollection.' => 1),
'bar')
2283 $result = $this->cObj->getImageSourceCollection($layoutKey, $configuration, $file);
2284 $this->assertSame(
$result,
'');
2292 public function getImageSourceCollectionRendersDefinedSources() {
2294 $cObj = $this->getMock(
2295 'TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer',
2296 array(
'stdWrap',
'getImgResource')
2298 $cObj->start(array(),
'tt_content');
2300 $layoutKey =
'test';
2302 $configuration = array(
2303 'layoutKey' =>
'test',
2304 'layout.' => array (
2306 'element' =>
'<img ###SRC### ###SRCCOLLECTION### ###SELFCLOSINGTAGSLASH###>',
2307 'source' =>
'---###SRC###---' 2310 'sourceCollection.' => array(
2317 $file =
'testImageName';
2321 ->expects($this->any())
2323 ->will($this->returnArgument(0));
2327 ->expects($this->exactly(1))
2328 ->method(
'getImgResource')
2329 ->with($this->equalTo(
'testImageName'))
2330 ->will($this->returnValue(array(100, 100, NULL,
'bar')));
2332 $result =
$cObj->getImageSourceCollection($layoutKey, $configuration, $file);
2334 $this->assertEquals(
'---bar---',
$result);
2347 $sourceCollectionArray = array(
2350 'srcsetCandidate' =>
'600w',
2351 'mediaQuery' =>
'(max-device-width: 600px)',
2352 'dataKey' =>
'small',
2354 'smallRetina.' => array(
2355 'if.directReturn' => 0,
2357 'pixelDensity' =>
'2',
2358 'srcsetCandidate' =>
'600w 2x',
2359 'mediaQuery' =>
'(max-device-width: 600px) AND (min-resolution: 192dpi)',
2360 'dataKey' =>
'smallRetina',
2367 'layoutKey' =>
'default',
2368 'layout.' => array (
2369 'default.' => array(
2370 'element' =>
'<img src="###SRC###" width="###WIDTH###" height="###HEIGHT###" ###PARAMS### ###ALTPARAMS### ###BORDER######SELFCLOSINGTAGSLASH###>',
2374 'sourceCollection.' => $sourceCollectionArray
2388 public function getImageSourceCollectionRendersDefinedLayoutKeyDefault($layoutKey , $configuration) {
2390 $cObj = $this->getMock(
2391 'TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer',
2392 array(
'stdWrap',
'getImgResource')
2394 $cObj->start(array(),
'tt_content');
2396 $file =
'testImageName';
2400 ->expects($this->any())
2402 ->will($this->returnArgument(0));
2404 $result =
$cObj->getImageSourceCollection($layoutKey, $configuration, $file);
2419 $sourceCollectionArray = array(
2422 'srcsetCandidate' =>
'600w',
2423 'mediaQuery' =>
'(max-device-width: 600px)',
2424 'dataKey' =>
'small',
2426 'smallRetina.' => array(
2427 'if.directReturn' => 1,
2429 'pixelDensity' =>
'2',
2430 'srcsetCandidate' =>
'600w 2x',
2431 'mediaQuery' =>
'(max-device-width: 600px) AND (min-resolution: 192dpi)',
2432 'dataKey' =>
'smallRetina',
2439 'layoutKey' =>
'srcset',
2440 'layout.' => array (
2442 'element' =>
'<img src="###SRC###" srcset="###SOURCECOLLECTION###" ###PARAMS### ###ALTPARAMS######SELFCLOSINGTAGSLASH###>',
2443 'source' =>
'|*|###SRC### ###SRCSETCANDIDATE###,|*|###SRC### ###SRCSETCANDIDATE###' 2446 'sourceCollection.' => $sourceCollectionArray
2449 'bar-file.jpg 600w,bar-file.jpg 600w 2x',
2454 'layoutKey' =>
'picture',
2455 'layout.' => array (
2456 'picture.' => array(
2457 'element' =>
'<picture>###SOURCECOLLECTION###<img src="###SRC###" ###PARAMS### ###ALTPARAMS######SELFCLOSINGTAGSLASH###></picture>',
2458 'source' =>
'<source src="###SRC###" media="###MEDIAQUERY###"###SELFCLOSINGTAGSLASH###>' 2461 'sourceCollection.' => $sourceCollectionArray,
2464 '<source src="bar-file.jpg" media="(max-device-width: 600px)" /><source src="bar-file.jpg" media="(max-device-width: 600px) AND (min-resolution: 192dpi)" />',
2469 'layoutKey' =>
'picture',
2470 'layout.' => array (
2471 'picture.' => array(
2472 'element' =>
'<picture>###SOURCECOLLECTION###<img src="###SRC###" ###PARAMS### ###ALTPARAMS######SELFCLOSINGTAGSLASH###></picture>',
2473 'source' =>
'<source src="###SRC###" media="###MEDIAQUERY###"###SELFCLOSINGTAGSLASH###>' 2476 'sourceCollection.' => $sourceCollectionArray,
2479 '<source src="bar-file.jpg" media="(max-device-width: 600px)"><source src="bar-file.jpg" media="(max-device-width: 600px) AND (min-resolution: 192dpi)">',
2484 'layoutKey' =>
'data',
2485 'layout.' => array (
2487 'element' =>
'<img src="###SRC###" ###SOURCECOLLECTION### ###PARAMS### ###ALTPARAMS######SELFCLOSINGTAGSLASH###>',
2488 'source' =>
'data-###DATAKEY###="###SRC###"' 2491 'sourceCollection.' => $sourceCollectionArray
2494 'data-small="bar-file.jpg"data-smallRetina="bar-file.jpg"',
2509 public function getImageSourceCollectionRendersDefinedLayoutKeyData($layoutKey , $configuration, $xhtmlDoctype, $expectedHtml) {
2511 $cObj = $this->getMock(
2512 'TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer',
2513 array(
'stdWrap',
'getImgResource')
2515 $cObj->start(array(),
'tt_content');
2517 $file =
'testImageName';
2519 $GLOBALS[
'TSFE']->xhtmlDoctype = $xhtmlDoctype;
2523 ->expects($this->any())
2525 ->will($this->returnArgument(0));
2529 ->expects($this->exactly(2))
2530 ->method(
'getImgResource')
2531 ->with($this->equalTo(
'testImageName'))
2532 ->will($this->returnValue(array(100, 100, NULL,
'bar-file.jpg')));
2534 $result =
$cObj->getImageSourceCollection($layoutKey, $configuration, $file);
2536 $this->assertEquals($expectedHtml,
$result);
2546 'TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer',
2547 array(
'getResourceFactory',
'stdWrap',
'getImgResource')
2549 $this->cObj->start(array(),
'tt_content');
2552 $this->cObj->expects($this->any())
2554 ->will($this->returnArgument(0));
2556 $this->cObj->expects($this->any())
2557 ->method(
'getImgResource')
2558 ->will($this->returnValue(array(100, 100, NULL,
'bar-file.jpg')));
2560 $resourceFactory = $this->getMock(
'TYPO3\\CMS\\Core\\Resource\\ResourceFactory', array(), array(),
'', FALSE);
2561 $this->cObj->expects($this->any())->method(
'getResourceFactory')->will($this->returnValue($resourceFactory));
2563 $className = $this->
getUniqueId(
'tx_coretest_getImageSourceCollectionHookCalled');
2564 $getImageSourceCollectionHookMock = $this->getMock(
'TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectOneSourceCollectionHookInterface', array(
'getOneSourceCollection'), array(), $className);
2565 $GLOBALS[
'T3_VAR'][
'getUserObj'][$className] = $getImageSourceCollectionHookMock;
2566 $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'getImageSourceCollection'][] = $className;
2568 $getImageSourceCollectionHookMock
2569 ->expects($this->exactly(1))
2570 ->method(
'getOneSourceCollection')
2571 ->will($this->returnCallback(array($this,
'isGetOneSourceCollectionCalledCallback')));
2573 $configuration = array(
2574 'layoutKey' =>
'data',
2575 'layout.' => array (
2577 'element' =>
'<img src="###SRC###" ###SOURCECOLLECTION### ###PARAMS### ###ALTPARAMS######SELFCLOSINGTAGSLASH###>',
2578 'source' =>
'data-###DATAKEY###="###SRC###"' 2581 'sourceCollection.' => array(
2584 'srcsetCandidate' =>
'600w',
2585 'mediaQuery' =>
'(max-device-width: 600px)',
2586 'dataKey' =>
'small',
2591 $result = $this->cObj->getImageSourceCollection(
'data', $configuration, $this->
getUniqueId(
'testImage-'));
2593 $this->assertSame(
$result,
'isGetOneSourceCollectionCalledCallback');
2603 list($sourceRenderConfiguration, $sourceConfiguration, $oneSourceCollection, $parent) = func_get_args();
2604 $this->assertTrue(is_array($sourceRenderConfiguration));
2605 $this->assertTrue(is_array($sourceConfiguration));
2606 return 'isGetOneSourceCollectionCalledCallback';
2618 $this->cObj->expects($this->any())->method(
'getEnvironmentVariable')->will($this->returnValueMap(
2620 array(
'HTTP_HOST',
'localhost'),
2621 array(
'TYPO3_SITE_PATH',
'/'),
2624 $GLOBALS[
'TSFE']->absRefPrefix =
'';
2626 $this->assertEquals($expected, $this->cObj->_call(
'forceAbsoluteUrl', $url, $configuration));
2634 'Missing forceAbsoluteUrl leaves URL untouched' => array(
2639 'Absolute URL stays unchanged' => array(
2640 'http://example.org/',
2641 'http://example.org/',
2643 'forceAbsoluteUrl' =>
'1' 2646 'Absolute URL stays unchanged 2' => array(
2647 'http://example.org/resource.html',
2648 'http://example.org/resource.html',
2650 'forceAbsoluteUrl' =>
'1' 2653 'Scheme and host w/o ending slash stays unchanged' => array(
2654 'http://example.org',
2655 'http://example.org',
2657 'forceAbsoluteUrl' =>
'1' 2660 'Scheme can be forced' => array(
2661 'typo3://example.org',
2662 'http://example.org',
2664 'forceAbsoluteUrl' =>
'1',
2665 'forceAbsoluteUrl.' => array(
2670 'Relative path old-style' => array(
2671 'http://localhost/fileadmin/dummy.txt',
2672 '/fileadmin/dummy.txt',
2674 'forceAbsoluteUrl' =>
'1',
2677 'Relative path' => array(
2678 'http://localhost/fileadmin/dummy.txt',
2679 'fileadmin/dummy.txt',
2681 'forceAbsoluteUrl' =>
'1',
2684 'Scheme can be forced with pseudo-relative path' => array(
2685 'typo3://localhost/fileadmin/dummy.txt',
2686 '/fileadmin/dummy.txt',
2688 'forceAbsoluteUrl' =>
'1',
2689 'forceAbsoluteUrl.' => array(
2694 'Hostname only is not treated as valid absolute URL' => array(
2695 'http://localhost/example.org',
2698 'forceAbsoluteUrl' =>
'1' 2701 'Scheme and host is added to local file path' => array(
2702 'typo3://localhost/fileadmin/my.pdf',
2705 'forceAbsoluteUrl' =>
'1',
2706 'forceAbsoluteUrl.' => array(
2719 $this->cObj->expects($this->any())->method(
'getEnvironmentVariable')->will($this->returnValueMap(
2721 array(
'HTTP_HOST',
'localhost'),
2722 array(
'TYPO3_SITE_PATH',
'/subfolder/'),
2726 $expected =
'http://localhost/subfolder/fileadmin/my.pdf';
2727 $url =
'fileadmin/my.pdf';
2728 $configuration = array(
2729 'forceAbsoluteUrl' =>
'1' 2732 $this->assertEquals($expected, $this->cObj->_call(
'forceAbsoluteUrl', $url, $configuration));
2741 'override.' => array(
2744 'data' =>
'TSFE:dtdAllowsFrames',
2757 'makelinks.' => array(
2759 'keep' =>
'{$styles.content.links.keep}',
2771 'typolink.' => array(
2772 'parameter.' => array(
2773 'data' =>
'parameters : allParams',
2778 'parseFunc.' => array(
2784 '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',
2786 'sword' =>
'<span class="csc-sword">|</span>',
2788 'nonTypoTagStdWrap.' => array(
2789 'HTMLparser' =>
'1',
2790 'HTMLparser.' => array(
2791 'keepNonMatchedTags' =>
'1',
2792 'htmlSpecialChars' =>
'2',
2804 'parseFunc.' => array(
2805 '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',
2808 'externalBlocks' =>
'article, aside, blockquote, div, dd, dl, footer, header, nav, ol, section, table, ul',
2809 'externalBlocks.' => array(
2810 'article.' => array(
2811 'callRecursive' =>
'1',
2815 'callRecursive' =>
'1',
2818 'blockquote.' => array(
2819 'callRecursive' =>
'1',
2823 'callRecursive' =>
'1',
2827 'callRecursive' =>
'1',
2831 'callRecursive' =>
'1',
2835 'callRecursive' =>
'1',
2839 'callRecursive' =>
'1',
2843 'callRecursive' =>
'1',
2847 'callRecursive' =>
'1',
2850 'section.' => array(
2851 'callRecursive' =>
'1',
2855 'HTMLtableCells' =>
'1',
2856 'HTMLtableCells.' => array(
2857 'addChr10BetweenParagraphs' =>
'1',
2858 'default.' => array(
2859 'stdWrap.' => array(
2860 'parseFunc' =>
'=< lib.parseFunc_RTE',
2861 'parseFunc.' => array(
2862 'nonTypoTagStdWrap.' => array(
2863 'encapsLines.' => array(
2864 'nonWrappedTag' =>
'',
2871 'stdWrap.' => array(
2872 'HTMLparser' =>
'1',
2873 'HTMLparser.' => array(
2874 'keepNonMatchedTags' =>
'1',
2877 'fixAttrib.' => array(
2880 'default' =>
'contenttable',
2881 'list' =>
'contenttable',
2891 'callRecursive' =>
'1',
2896 'makelinks.' => array(
2898 'extTarget.' => array(
2899 'override' =>
'_blank',
2900 'override.' => array(
2903 'data' =>
'TSFE:dtdAllowsFrames',
2911 'nonTypoTagStdWrap.' => array(
2912 'encapsLines.' => array(
2913 'addAttributes.' => array(
2915 'class' =>
'bodytext',
2917 'setOnly' =>
'blank',
2921 'encapsTagList' =>
'p,pre,h1,h2,h3,h4,h5,h6,hr,dt,li',
2922 'innerStdWrap_all.' => array(
2923 'ifBlank' =>
' ',
2925 'nonWrappedTag' =>
'P',
2926 'remapTag.' => array(
2930 'HTMLparser' =>
'1',
2931 'HTMLparser.' => array(
2932 'htmlSpecialChars' =>
'2',
2933 'keepNonMatchedTags' =>
'1',
2936 'sword' =>
'<span class="csc-sword">|</span>',
2941 'parseFunc.' => array(
2944 'typolink.' => array(
2945 'extTarget.' => array(
2947 'override.' => array(
2950 'data' =>
'TSFE:dtdAllowsFrames',
2955 'parameter.' => array(
2956 'data' =>
'parameters : allParams',
2960 'override.' => array(
2963 'data' =>
'TSFE:dtdAllowsFrames',
2980 'Text without tag is wrapped with <p> tag' => array(
2983 '<p class="bodytext">Text without tag</p>',
2985 'Text wrapped with <p> tag remains the same' => array(
2986 '<p class="myclass">Text with <p> tag</p>',
2988 '<p class="myclass">Text with <p> tag</p>',
2990 'Text with absolute external link' => array(
2991 'Text with <link http://example.com/foo/>external link</link>',
2993 '<p class="bodytext">Text with <a href="http://example.com/foo/">external link</a></p>',
3006 $this->assertEquals($expectedResult, $this->cObj->stdWrap_parseFunc($value, $configuration));
3020 $typoScript = array(
'parameter' => $mailAddress);
3022 $this->assertEquals($expected, $this->cObj->typoLink($linkText, $typoScript));
3030 'plain mail without mailto scheme' => array(
3032 'spamProtectEmailAddresses' =>
'',
3033 'spamProtectEmailAddresses_atSubst' =>
'',
3034 'spamProtectEmailAddresses_lastDotSubst' =>
'',
3036 'some.body@test.typo3.org',
3037 'some.body@test.typo3.org',
3038 '<a href="mailto:some.body@test.typo3.org">some.body@test.typo3.org</a>',
3040 'plain mail with mailto scheme' => array(
3042 'spamProtectEmailAddresses' =>
'',
3043 'spamProtectEmailAddresses_atSubst' =>
'',
3044 'spamProtectEmailAddresses_lastDotSubst' =>
'',
3046 'some.body@test.typo3.org',
3047 'mailto:some.body@test.typo3.org',
3048 '<a href="mailto:some.body@test.typo3.org">some.body@test.typo3.org</a>',
3050 'plain with at and dot substitution' => array(
3052 'spamProtectEmailAddresses' =>
'0',
3053 'spamProtectEmailAddresses_atSubst' =>
'(at)',
3054 'spamProtectEmailAddresses_lastDotSubst' =>
'(dot)',
3056 'some.body@test.typo3.org',
3057 'mailto:some.body@test.typo3.org',
3058 '<a href="mailto:some.body@test.typo3.org">some.body@test.typo3.org</a>',
3060 'mono-alphabetic substitution offset +1' => array(
3062 'spamProtectEmailAddresses' =>
'1',
3063 'spamProtectEmailAddresses_atSubst' =>
'',
3064 'spamProtectEmailAddresses_lastDotSubst' =>
'',
3066 'some.body@test.typo3.org',
3067 'mailto:some.body@test.typo3.org',
3068 '<a href="javascript:linkTo_UnCryptMailto(\'nbjmup+tpnf/cpezAuftu/uzqp4/psh\');">some.body(at)test.typo3.org</a>',
3070 'mono-alphabetic substitution offset +1 with at substitution' => array(
3072 'spamProtectEmailAddresses' =>
'1',
3073 'spamProtectEmailAddresses_atSubst' =>
'@',
3074 'spamProtectEmailAddresses_lastDotSubst' =>
'',
3076 'some.body@test.typo3.org',
3077 'mailto:some.body@test.typo3.org',
3078 '<a href="javascript:linkTo_UnCryptMailto(\'nbjmup+tpnf/cpezAuftu/uzqp4/psh\');">some.body@test.typo3.org</a>',
3080 'mono-alphabetic substitution offset +1 with at and dot substitution' => array(
3082 'spamProtectEmailAddresses' =>
'1',
3083 'spamProtectEmailAddresses_atSubst' =>
'(at)',
3084 'spamProtectEmailAddresses_lastDotSubst' =>
'(dot)',
3086 'some.body@test.typo3.org',
3087 'mailto:some.body@test.typo3.org',
3088 '<a href="javascript:linkTo_UnCryptMailto(\'nbjmup+tpnf/cpezAuftu/uzqp4/psh\');">some.body(at)test.typo3(dot)org</a>',
3090 'mono-alphabetic substitution offset -1 with at and dot substitution' => array(
3092 'spamProtectEmailAddresses' =>
'-1',
3093 'spamProtectEmailAddresses_atSubst' =>
'(at)',
3094 'spamProtectEmailAddresses_lastDotSubst' =>
'(dot)',
3096 'some.body@test.typo3.org',
3097 'mailto:some.body@test.typo3.org',
3098 '<a href="javascript:linkTo_UnCryptMailto(\'lzhksn9rnld-ancxZsdrs-sxon2-nqf\');">some.body(at)test.typo3(dot)org</a>',
3100 'entity substitution with at and dot substitution' => array(
3102 'spamProtectEmailAddresses' =>
'ascii',
3103 'spamProtectEmailAddresses_atSubst' =>
'',
3104 'spamProtectEmailAddresses_lastDotSubst' =>
'',
3106 'some.body@test.typo3.org',
3107 'mailto:some.body@test.typo3.org',
3108 '<a href="mailto:some.body@test.typo3.org">some.body(at)test.typo3.org</a>',
3110 'entity substitution with at and dot substitution with at and dot substitution' => array(
3112 'spamProtectEmailAddresses' =>
'ascii',
3113 'spamProtectEmailAddresses_atSubst' =>
'(at)',
3114 'spamProtectEmailAddresses_lastDotSubst' =>
'(dot)',
3116 'some.body@test.typo3.org',
3117 'mailto:some.body@test.typo3.org',
3118 '<a href="mailto:some.body@test.typo3.org">some.body(at)test.typo3(dot)org</a>',
3129 'Link to url' => array(
3132 'parameter' =>
'http://typo3.org',
3134 '<a href="http://typo3.org">TYPO3</a>',
3136 'Link to url without link text' => array(
3139 'parameter' =>
'http://typo3.org',
3141 '<a href="http://typo3.org">http://typo3.org</a>',
3143 'Link to url with attributes' => array(
3146 'parameter' =>
'http://typo3.org',
3147 'ATagParams' =>
'class="url-class"',
3148 'extTarget' =>
'_blank',
3149 'title' =>
'Open new window',
3151 '<a href="http://typo3.org" title="Open new window" target="_blank" class="url-class">TYPO3</a>',
3153 'Link to url with attributes in parameter' => array(
3156 'parameter' =>
'http://typo3.org _blank url-class "Open new window"',
3158 '<a href="http://typo3.org" title="Open new window" target="_blank" class="url-class">TYPO3</a>',
3160 'Link to url with script tag' => array(
3163 'parameter' =>
'http://typo3.org<script>alert(123)</script>',
3165 '<a href="http://typo3.org<script>alert(123)</script>">http://typo3.org<script>alert(123)</script></a>',
3167 'Link to email address' => array(
3170 'parameter' =>
'foo@bar.org',
3172 '<a href="mailto:foo@bar.org">Email address</a>',
3174 'Link to email address without link text' => array(
3177 'parameter' =>
'foo@bar.org',
3179 '<a href="mailto:foo@bar.org">foo@bar.org</a>',
3181 'Link to email with attributes' => array(
3184 'parameter' =>
'foo@bar.org',
3185 'ATagParams' =>
'class="email-class"',
3186 'title' =>
'Write an email',
3188 '<a href="mailto:foo@bar.org" title="Write an email" class="email-class">Email address</a>',
3190 'Link to email with attributes in parameter' => array(
3193 'parameter' =>
'foo@bar.org - email-class "Write an email"',
3195 '<a href="mailto:foo@bar.org" title="Write an email" class="email-class">Email address</a>',
3208 $templateServiceObjectMock = $this->getMock(
'TYPO3\\CMS\\Core\\TypoScript\\TemplateService', array(
'dummy'));
3209 $templateServiceObjectMock->setup = array(
3214 $typoScriptFrontendControllerMockObject = $this->getMock(
'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', array(), array(),
'', FALSE);
3215 $typoScriptFrontendControllerMockObject->config = array(
3216 'config' => array(),
3217 'mainScript' =>
'index.php',
3219 $typoScriptFrontendControllerMockObject->tmpl = $templateServiceObjectMock;
3220 $GLOBALS[
'TSFE'] = $typoScriptFrontendControllerMockObject;
3222 $this->assertEquals($expectedResult, $this->cObj->typoLink($linkText, $configuration));
3230 'Link to page' => array(
3237 'title' =>
'Page title',
3239 '<a href="index.php?id=42">My page</a>',
3241 'Link to page without link text' => array(
3248 'title' =>
'Page title',
3250 '<a href="index.php?id=42">Page title</a>',
3252 'Link to page with attributes' => array(
3255 'parameter' =>
'42',
3256 'ATagParams' =>
'class="page-class"',
3257 'target' =>
'_self',
3258 'title' =>
'Link to internal page',
3262 'title' =>
'Page title',
3264 '<a href="index.php?id=42" title="Link to internal page" target="_self" class="page-class">My page</a>',
3266 'Link to page with attributes in parameter' => array(
3269 'parameter' =>
'42 _self page-class "Link to internal page"',
3273 'title' =>
'Page title',
3275 '<a href="index.php?id=42" title="Link to internal page" target="_self" class="page-class">My page</a>',
3277 'Link to page with bold tag in title' => array(
3284 'title' =>
'Page <b>title</b>',
3286 '<a href="index.php?id=42">Page <b>title</b></a>',
3288 'Link to page with script tag in title' => array(
3295 'title' =>
'<script>alert(123)</script>Page title',
3297 '<a href="index.php?id=42"><script>alert(123)</script>Page title</a>',
3311 $pageRepositoryMockObject = $this->getMock(
'TYPO3\\CMS\\Frontend\\Page\\PageRepository', array(
'getPage'));
3312 $pageRepositoryMockObject->expects($this->any())->method(
'getPage')->willReturn($pageArray);
3313 $templateServiceObjectMock = $this->getMock(
'TYPO3\\CMS\\Core\\TypoScript\\TemplateService', array(
'dummy'));
3314 $templateServiceObjectMock->setup = array(
3319 $typoScriptFrontendControllerMockObject = $this->getMock(
'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', array(), array(),
'', FALSE);
3320 $typoScriptFrontendControllerMockObject->config = array(
3321 'config' => array(),
3322 'mainScript' =>
'index.php',
3324 $typoScriptFrontendControllerMockObject->sys_page = $pageRepositoryMockObject;
3325 $typoScriptFrontendControllerMockObject->tmpl = $templateServiceObjectMock;
3326 $GLOBALS[
'TSFE'] = $typoScriptFrontendControllerMockObject;
3328 $this->assertEquals($expectedResult, $this->cObj->typoLink($linkText, $configuration));
3336 'Link to file' => array(
3339 'parameter' =>
'fileadmin/foo.bar',
3341 '<a href="fileadmin/foo.bar">My file</a>',
3343 'Link to file without link text' => array(
3346 'parameter' =>
'fileadmin/foo.bar',
3348 '<a href="fileadmin/foo.bar">fileadmin/foo.bar</a>',
3350 'Link to file with attributes' => array(
3353 'parameter' =>
'fileadmin/foo.bar',
3354 'ATagParams' =>
'class="file-class"',
3355 'fileTarget' =>
'_blank',
3356 'title' =>
'Title of the file',
3358 '<a href="fileadmin/foo.bar" title="Title of the file" target="_blank" class="file-class">My file</a>',
3360 'Link to file with attributes in parameter' => array(
3363 'parameter' =>
'fileadmin/foo.bar _blank file-class "Title of the file"',
3365 '<a href="fileadmin/foo.bar" title="Title of the file" target="_blank" class="file-class">My file</a>',
3367 'Link to file with script tag in name' => array(
3370 'parameter' =>
'fileadmin/<script>alert(123)</script>',
3372 '<a href="fileadmin/<script>alert(123)</script>">fileadmin/<script>alert(123)</script></a>',
3385 $templateServiceObjectMock = $this->getMock(
'TYPO3\\CMS\\Core\\TypoScript\\TemplateService', array(
'dummy'));
3386 $templateServiceObjectMock->setup = array(
3391 $typoScriptFrontendControllerMockObject = $this->getMock(
'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', array(), array(),
'', FALSE);
3392 $typoScriptFrontendControllerMockObject->config = array(
3393 'config' => array(),
3394 'mainScript' =>
'index.php',
3396 $typoScriptFrontendControllerMockObject->tmpl = $templateServiceObjectMock;
3397 $GLOBALS[
'TSFE'] = $typoScriptFrontendControllerMockObject;
3399 $this->assertEquals($expectedResult, $this->cObj->typoLink($linkText, $configuration));
3407 'no markers defined' => array(
3408 'dummy content with ###UNREPLACED### marker',
3412 'dummy content with ###UNREPLACED### marker',
3416 'no markers used' => array(
3417 'dummy content with no marker',
3419 '###REPLACED###' =>
'_replaced_' 3423 'dummy content with no marker',
3427 'one marker' => array(
3428 'dummy content with ###REPLACED### marker',
3430 '###REPLACED###' =>
'_replaced_' 3434 'dummy content with _replaced_ marker' 3436 'one marker with lots of chars' => array(
3437 'dummy content with ###RE.:##-=_()LACED### marker',
3439 '###RE.:##-=_()LACED###' =>
'_replaced_' 3443 'dummy content with _replaced_ marker' 3445 'markers which are special' => array(
3446 'dummy ###aa##.#######A### ######',
3448 '###aa##.###' =>
'content ',
3450 '######' =>
'-is not considered-' 3454 'dummy content #is ######' 3456 'two markers in content, but more defined' => array(
3457 'dummy ###CONTENT### with ###REPLACED### marker',
3459 '###REPLACED###' =>
'_replaced_',
3460 '###CONTENT###' =>
'content',
3461 '###NEVERUSED###' =>
'bar' 3465 'dummy content with _replaced_ marker' 3467 'one subpart' => array(
3468 'dummy content with ###ASUBPART### around some text###ASUBPART###.',
3471 '###ASUBPART###' =>
'some other text' 3474 'dummy content with some other text.' 3476 'one wrapped subpart' => array(
3477 'dummy content with ###AWRAPPEDSUBPART### around some text###AWRAPPEDSUBPART###.',
3481 '###AWRAPPEDSUBPART###' => array(
3486 'dummy content with more content around some textcontent.' 3488 'one subpart with markers, not replaced recursively' => array(
3489 'dummy ###CONTENT### with ###ASUBPART### around ###SOME### text###ASUBPART###.',
3491 '###CONTENT###' =>
'content',
3492 '###SOME###' =>
'-this should never make it into output-',
3493 '###OTHER_NOT_REPLACED###' =>
'-this should never make it into output-' 3496 '###ASUBPART###' =>
'some ###OTHER_NOT_REPLACED### text' 3499 'dummy content with some ###OTHER_NOT_REPLACED### text.' 3516 public function substituteMarkerArrayCachedReturnsExpectedContent($content, array $markContentArray, array $subpartContentArray, array $wrappedSubpartContentArray, $expectedContent, $shouldQueryCache =
true, $shouldStoreCache =
true) {
3518 $pageRepo = $this->tsfe->sys_page;
3519 $pageRepo->resetCallCount();
3521 $resultContent = $this->cObj->substituteMarkerArrayCached($content, $markContentArray, $subpartContentArray, $wrappedSubpartContentArray);
3523 $this->assertSame((
int)$shouldQueryCache, $pageRepo::$getHashCallCount,
'getHash call count mismatch');
3524 $this->assertSame((
int)$shouldStoreCache, $pageRepo::$storeHashCallCount,
'storeHash call count mismatch');
3525 $this->assertSame($expectedContent, $resultContent);
3531 public function substituteMarkerArrayCachedRetrievesCachedValueFromRuntimeCache() {
3533 $pageRepo = $this->tsfe->sys_page;
3534 $pageRepo->resetCallCount();
3536 $content =
'Please tell me this ###FOO###.';
3537 $markContentArray = array(
3538 '###FOO###' =>
'foo',
3539 '###NOTUSED###' =>
'blub' 3541 $storeKey = md5(
'substituteMarkerArrayCached_storeKey:' . serialize(array($content, array_keys($markContentArray))));
3542 $this->cObj->substMarkerCache[$storeKey] = array(
3544 'Please tell me this ',
3551 $resultContent = $this->cObj->substituteMarkerArrayCached($content, $markContentArray);
3552 $this->assertSame(0, $pageRepo::$getHashCallCount);
3553 $this->assertSame(
'Please tell me this foo.', $resultContent);
3559 public function substituteMarkerArrayCachedRetrievesCachedValueFromDbCache() {
3561 $pageRepo = $this->tsfe->sys_page;
3562 $pageRepo->resetCallCount();
3564 $content =
'Please tell me this ###FOO###.';
3565 $markContentArray = array(
3566 '###FOO###' =>
'foo',
3567 '###NOTUSED###' =>
'blub' 3569 $pageRepo::$dbCacheContent = array(
3571 'Please tell me this ',
3578 $resultContent = $this->cObj->substituteMarkerArrayCached($content, $markContentArray);
3579 $this->assertSame(1, $pageRepo::$getHashCallCount,
'getHash call count mismatch');
3580 $this->assertSame(0, $pageRepo::$storeHashCallCount,
'storeHash call count mismatch');
3581 $this->assertSame(
'Please tell me this foo.', $resultContent);
3587 public function substituteMarkerArrayCachedStoresResultInCaches() {
3589 $pageRepo = $this->tsfe->sys_page;
3590 $pageRepo->resetCallCount();
3592 $content =
'Please tell me this ###FOO###.';
3593 $markContentArray = array(
3594 '###FOO###' =>
'foo',
3595 '###NOTUSED###' =>
'blub' 3597 $resultContent = $this->cObj->substituteMarkerArrayCached($content, $markContentArray);
3599 $storeKey = md5(
'substituteMarkerArrayCached_storeKey:' . serialize(array($content, array_keys($markContentArray))));
3602 'Please tell me this ',
3609 $this->assertSame(1, $pageRepo::$getHashCallCount);
3610 $this->assertSame(
'Please tell me this foo.', $resultContent);
3611 $this->assertSame($storeArr, $this->cObj->substMarkerCache[$storeKey]);
3612 $this->assertSame(1, $pageRepo::$storeHashCallCount);
typolinkReturnsCorrectLinksForPagesDataProvider()
cropHtmlWorksWithComplexContent()
stdWrap_ifNullDeterminesNullValuesDataProvider()
numberFormat($float, $formatConf, $expected)
getImageTagTemplateFallsBackToDefaultTemplateIfNoTemplateIsFound($key, $configuration)
getDataWithTypeLeveltitle()
getQueryCallsGetTreeListWithNegativeValuesIfRecursiveIsSet()
stdWrap_addPageCacheTagsAddsPageTagsDataProvider()
getImageSourceCollectionHookCalled()
getDataWithTypeGpDataProvider()
getImageTagTemplateReturnTemplateElementIdentifiedByKeyDataProvider()
static addInstance($className, $instance)
typoLinkEncodesMailAddressForSpamProtectionDataProvider()
getQueryArgumentsWithMethodGetPostMergesParameters()
getDataWithTypeLevelfield()
stdWrap_noTrimWrapAcceptsSplitCharDataProvider()
rawUrlEncodeSquareBracketsInUrl($string)
stdWrap_hash($text, array $conf, $expected)
getDataWithTypeDebugData()
cropHtmlWorksWithLinebreaks()
typolinkReturnsCorrectLinksForPages($linkText, $configuration, $pageArray, $expectedResult)
getQueryCallsGetTreeListWithCurrentPageIfThisIsSet()
getDataWithTypeDebugPage()
getDataWithTypeLeveluid()
typoLinkEncodesMailAddressForSpamProtection(array $settings, $linkText, $mailAddress, $expected)
forceAbsoluteUrlReturnsCorrectAbsoluteUrlDataProvider()
getImageSourceCollectionReturnsEmptyStringIfNoSourcesAreDefined($layoutKey, $configuration, $file)
cropHtmlWithDataProvider($settings, $subject, $expected, $charset)
getDataWithTypeDebugRootline()
getDataWithTypeGetindpenv()
formWithSecureFormMailEnabledDoesNotContainRecipientField()
typolinkReturnsCorrectLinksFilesDataProvider()
numberFormatDataProvider()
getDataWithTypeRegister()
getImageTagTemplateFallsBackToDefaultTemplateIfNoTemplateIsFoundDataProvider()
stdWrap_encodeForJavaScriptValue($input, $conf, $expected)
stdWrap_strPadDataProvider()
stdWrap_addPageCacheTagsAddsPageTags(array $expectedTags, array $configuration)
_parseFuncReturnsCorrectHtmlDataProvider()
getContentObjectValidContentObjectsDataProvider()
typolinkReturnsCorrectLinksForEmailsAndUrlsDataProvider()
getImageSourceCollectionRendersDefinedLayoutKeyDataDefaultProvider()
getTreeListReturnsChildPageUids()
getDataWithTypeDebugFullRootline()
aTagParamsHaveSpaceBetweenLocalAndGlobalParams()
replacementDataProvider()
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
substituteMarkerArrayCachedReturnsExpectedContentDataProvider()
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
forceAbsoluteUrlReturnsCorrectAbsoluteUrl($expected, $url, array $configuration)
stdWrap_noTrimWrapAcceptsSplitChar($content, array $configuration, $expected)
getQueryArgumentsOverrulesMultiDimensionalForcedParameters()
getDataWithTypeParentRecordNumber()
getQueryArgumentsOverrulesSingleParameter()
getDataWithTypeLevelmedia()
formWithSecureFormMailDisabledDoesNotContainRecipientField()
getDataWithTypeFullrootline()
getDataWithTypeDebugRegister()
getDataWithTypeParameters()
typolinkReturnsCorrectLinksFiles($linkText, $configuration, $expectedResult)
getQueryArgumentsWithMethodPostGetMergesParameters()
stdWrap_encodeForJavaScriptValueDataProvider()
aTagParamsHasLeadingSpaceIfNotEmpty()
getContentObjectCallsMakeInstanceForNewContentObjectInstance($name, $className)
isGetOneSourceCollectionCalledCallback()
getQuery($table, $conf, $expected)
stdWrap_roundDataProvider()
stdWrap_strPad($content, $conf, $expected)
stdWrap_ifNullDeterminesNullValues($content, array $configuration, $expected)
getImgResourceCallsGetImgResourcePostProcessHook()
typolinkReturnsCorrectLinksForEmailsAndUrls($linkText, $configuration, $expectedResult)
aTagParamsHasNoLeadingSpaceIfEmpty()
getDataWithTypeGp($key, $expectedValue)
getQueryArgumentsExcludesParameters()
forceAbsoluteUrlReturnsCorrectAbsoluteUrlWithSubfolder()
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
getDataWithTypeFileReturnsUidOfFileObject()
getQueryArgumentsOverrulesMultiDimensionalParameters()
getImageSourceCollectionReturnsEmptyStringIfNoSourcesAreDefinedDataProvider()
stdWrap_strftimeReturnsFormattedStringDataProvider()
replacement($input, $conf, $expected)
getImageSourceCollectionRendersDefinedLayoutKeyDataDataProvider()
stdWrap_round($float, $conf, $expected)
getTreeListReturnsChildPageUidsAndOriginalPidForNegativeValue()
getImageTagTemplateReturnTemplateElementIdentifiedByKey($key, $configuration, $expectation)
isGetImgResourceHookCalledCallback()
getQueryArgumentsExcludesGetParameters()
stdWrap_strftimeReturnsFormattedString($content, $conf)
handleCharset($charset, &$subject, &$expected)
stdWrap_parseFuncReturnsParsedHtml($value, $configuration, $expectedResult)