35 protected function setUp()
39 $typoScriptFrontendController = GeneralUtility::makeInstance(
40 TypoScriptFrontendController::class,
45 $typoScriptFrontendController->sys_page = GeneralUtility::makeInstance(PageRepository::class);
46 $typoScriptFrontendController->tmpl = GeneralUtility::makeInstance(TemplateService::class);
47 $GLOBALS[
'TSFE'] = $typoScriptFrontendController;
49 $this->subject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
61 'testing empty conf' => [
68 'testing #17284: adding uid/pid for workspaces' => [
71 'selectFields' =>
'header,bodytext'
74 'SELECT' =>
'header,bodytext, [tt_content].[uid] AS [uid], [tt_content].[pid] AS [pid], [tt_content].[t3ver_state] AS [t3ver_state]'
77 'testing #17284: no need to add' => [
80 'selectFields' =>
'tt_content.*'
83 'SELECT' =>
'tt_content.*'
86 'testing #17284: no need to add #2' => [
95 'testing #29783: joined tables, prefix tablename' => [
98 'selectFields' =>
'tt_content.header,be_users.username',
99 'join' =>
'be_users ON tt_content.cruser_id = be_users.uid'
102 'SELECT' =>
'tt_content.header,be_users.username, [tt_content].[uid] AS [uid], [tt_content].[pid] AS [pid], [tt_content].[t3ver_state] AS [t3ver_state]'
105 'testing #34152: single count(*), add nothing' => [
108 'selectFields' =>
'count(*)'
111 'SELECT' =>
'count(*)'
114 'testing #34152: single max(crdate), add nothing' => [
117 'selectFields' =>
'max(crdate)'
120 'SELECT' =>
'max(crdate)'
123 'testing #34152: single min(crdate), add nothing' => [
126 'selectFields' =>
'min(crdate)'
129 'SELECT' =>
'min(crdate)'
132 'testing #34152: single sum(is_siteroot), add nothing' => [
135 'selectFields' =>
'sum(is_siteroot)'
138 'SELECT' =>
'sum(is_siteroot)'
141 'testing #34152: single avg(crdate), add nothing' => [
144 'selectFields' =>
'avg(crdate)'
147 'SELECT' =>
'avg(crdate)'
150 'single distinct, add nothing' => [
153 'selectFields' =>
'DISTINCT crdate'
156 'SELECT' =>
'DISTINCT crdate'
173 public function getQuery(
string $table, array $conf, array $expected)
179 'disabled' =>
'hidden'
186 'disabled' =>
'hidden'
188 'versioningWS' => true
193 $result = $this->subject->getQuery($table, $conf,
true);
195 $databasePlatform = (
new ConnectionPool())->getConnectionForTable(
'tt_content')->getDatabasePlatform();
196 foreach ($expected as $field => $value) {
197 if (!($databasePlatform instanceof \Doctrine\DBAL\Platforms\SQLServerPlatform)) {
199 if ($field ===
'SELECT') {
200 $quoteChar = $databasePlatform->getIdentifierQuoteCharacter();
201 $value = str_replace([
'[',
']'], [$quoteChar, $quoteChar], $value);
204 $this->assertEquals($value, $result[$field]);
213 $this->subject = $this->getAccessibleMock(ContentObjectRenderer::class, [
'getTreeList']);
214 $this->subject->start([],
'tt_content');
218 'pidInList' =>
'16, -35'
221 $this->subject->expects($this->at(0))
222 ->method(
'getTreeList')
224 ->will($this->returnValue(
'15,16'));
225 $this->subject->expects($this->at(1))
226 ->method(
'getTreeList')
228 ->will($this->returnValue(
'15,35'));
230 $this->subject->getQuery(
'tt_content', $conf,
true);
240 $this->subject = $this->getAccessibleMock(ContentObjectRenderer::class, [
'getTreeList']);
241 $this->subject->start([],
'tt_content');
244 'pidInList' =>
'this',
248 $this->subject->expects($this->once())
249 ->method(
'getTreeList')
251 ->will($this->returnValue(
'27'));
253 $this->subject->getQuery(
'tt_content', $conf,
true);
275 'where' =>
'tt_content.cruser_id=5',
276 'groupBy' =>
'tt_content.title',
277 'orderBy' =>
'tt_content.sorting',
279 'WHERE (`tt_content`.`uid` IN (42)) AND (`tt_content`.`pid` IN (43)) AND (tt_content.cruser_id=5) GROUP BY `tt_content`.`title` ORDER BY `tt_content`.`sorting`',
285 'delete' =>
'deleted',
287 'disabled' =>
'hidden',
288 'starttime' =>
'startdate',
289 'endtime' =>
'enddate',
291 'languageField' =>
'sys_language_uid',
292 'transOrigPointerField' =>
'l18n_parent',
302 'where' =>
'tt_content.cruser_id=5',
303 'groupBy' =>
'tt_content.title',
304 'orderBy' =>
'tt_content.sorting',
306 'WHERE (`tt_content`.`uid` IN (42)) AND (`tt_content`.`pid` IN (43)) AND (tt_content.cruser_id=5) AND (`tt_content`.`sys_language_uid` = 13) 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`',
312 'languageField' =>
'sys_language_uid',
313 'transOrigPointerField' =>
'l18n_parent',
323 'where' =>
'tt_content.cruser_id=5',
324 'languageField' => 0,
326 'WHERE (`tt_content`.`uid` IN (42)) AND (`tt_content`.`pid` IN (43)) AND (tt_content.cruser_id=5)',
344 'title' =>
'Page title',
346 '<a href="index.php?id=42">My page</a>',
348 'Link to page without link text' => [
355 'title' =>
'Page title',
357 '<a href="index.php?id=42">Page title</a>',
359 'Link to page with attributes' => [
363 'ATagParams' =>
'class="page-class"',
365 'title' =>
'Link to internal page',
369 'title' =>
'Page title',
371 '<a href="index.php?id=42" title="Link to internal page" target="_self" class="page-class">My page</a>',
373 'Link to page with attributes in parameter' => [
376 'parameter' =>
'42 _self page-class "Link to internal page"',
380 'title' =>
'Page title',
382 '<a href="index.php?id=42" title="Link to internal page" target="_self" class="page-class">My page</a>',
384 'Link to page with bold tag in title' => [
391 'title' =>
'Page <b>title</b>',
393 '<a href="index.php?id=42">Page <b>title</b></a>',
395 'Link to page with script tag in title' => [
402 'title' =>
'<script>alert(123)</script>Page title',
404 '<a href="index.php?id=42"><script>alert(123)</script>Page title</a>',
422 $this->markTestIncomplete(
'This test has side effects and is based on non-asserted assumptions');
424 $pageRepositoryMockObject = $this->getMockBuilder(PageRepository::class)
425 ->setMethods([
'getPage'])
427 $pageRepositoryMockObject->expects($this->any())->method(
'getPage')->willReturn($pageArray);
429 $typoScriptFrontendController = $this->getMockBuilder(TypoScriptFrontendController::class)
430 ->setConstructorArgs([
null, 1, 0])
431 ->setMethods([
'dummy'])
433 $typoScriptFrontendController->config = [
436 $typoScriptFrontendController->sys_page = $pageRepositoryMockObject;
437 $typoScriptFrontendController->tmpl = GeneralUtility::makeInstance(TemplateService::class);
438 $typoScriptFrontendController->tmpl->setup = [
443 $GLOBALS[
'TSFE'] = $typoScriptFrontendController;
445 $subject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
446 $this->assertEquals($expectedResult,
$subject->
typoLink($linkText, $configuration));
454 $expected =
'<a href="mailto:test@example.com">Send me an email</a>';
456 $result =
$subject->
typoLink(
'Send me an email', [
'parameter' =>
'mailto:test@example.com']);
457 self::assertEquals($expected, $result);
459 $result =
$subject->
typoLink(
'Send me an email', [
'parameter' =>
'test@example.com']);
460 self::assertEquals($expected, $result);
468 $tsfe = $this->getMockBuilder(TypoScriptFrontendController::class)->disableOriginalConstructor()->getMock();
469 $subject =
new ContentObjectRenderer($tsfe);
471 $tsfe->spamProtectEmailAddresses = 1;
472 $result =
$subject->
typoLink(
'Send me an email', [
'parameter' =>
'mailto:test@example.com']);
473 self::assertEquals(
'<a href="javascript:linkTo_UnCryptMailto(%27nbjmup%2BuftuAfybnqmf%5C%2Fdpn%27);">Send me an email</a>', $result);
475 $tsfe->spamProtectEmailAddresses =
'ascii';
476 $result =
$subject->
typoLink(
'Send me an email', [
'parameter' =>
'mailto:test@example.com']);
477 self::assertEquals(
'<a href="mailto:test@example.com">Send me an email</a>', $result);
488 $this->markTestIncomplete(
'This test has side effects and is based on non-asserted assumptions');
490 $pageRepositoryMockObject = $this->getMockBuilder(PageRepository::class)
491 ->setMethods([
'getPage'])
493 $pageRepositoryMockObject->expects($this->any())->method(
'getPage')->willReturn([
495 'title' =>
'Page title',
498 $templateServiceMockObject = $this->getMockBuilder(TemplateService::class)
500 $templateServiceMockObject->setup = [
506 $subject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
507 $pageLinkBuilder = $this->getMockBuilder(PageLinkBuilder::class)
508 ->setMethods([
'createTotalUrlAndLinkData'])
511 $pageLinkBuilder->expects($this::once())->method(
'createTotalUrlAndLinkData')->willReturn([
512 'url' =>
'/index.php?id=1',
518 'sectionIndex' =>
'',
521 GeneralUtility::addInstance(PageLinkBuilder::class, $pageLinkBuilder);
523 $typoScriptFrontendController = $this->getMockBuilder(TypoScriptFrontendController::class)
524 ->setConstructorArgs([
null, 1, 0])
525 ->setMethods([
'dummy'])
527 $typoScriptFrontendController->config = [
530 $typoScriptFrontendController->sys_page = $pageRepositoryMockObject;
531 $typoScriptFrontendController->tmpl = $templateServiceMockObject;
532 $GLOBALS[
'TSFE'] = $typoScriptFrontendController;
536 'section' =>
'content',
539 $this->assertEquals(
'<a href="#content">Page title</a>',
$subject->
typoLink(
'', $configuration));
547 $tsfe = $this->getMockBuilder(TypoScriptFrontendController::class)->disableOriginalConstructor()->getMock();
548 $subject =
new ContentObjectRenderer($tsfe);
553 $this->assertEquals($expected, $actual);
565 'keep' =>
'{$styles.content.links.keep}',
578 'data' =>
'parameters : allParams',
587 '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',
589 'sword' =>
'<span class="csc-sword">|</span>',
591 'nonTypoTagStdWrap.' => [
594 'keepNonMatchedTags' =>
'1',
595 'htmlSpecialChars' =>
'2',