‪TYPO3CMS  11.5
ContentObjectRendererTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Doctrine\DBAL\Platforms\SQLServer2012Platform as SQLServerPlatform;
21 use Prophecy\PhpUnit\ProphecyTrait;
22 use Psr\Http\Message\ServerRequestInterface;
23 use Psr\Log\NullLogger;
34 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
36 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
37 
41 class ‪ContentObjectRendererTest extends FunctionalTestCase
42 {
43  use ProphecyTrait;
45 
49  protected const ‪LANGUAGE_PRESETS = [
50  'EN' => ['id' => 0, 'title' => 'English', 'locale' => 'en_US.UTF8'],
51  ];
52 
56  protected ‪$subject;
57 
62 
63  protected ‪$pathsToProvideInTestInstance = ['typo3/sysext/frontend/Tests/Functional/Fixtures/Images' => 'fileadmin/user_upload'];
64 
65  protected function ‪setUp(): void
66  {
67  parent::setUp();
68  $this->setUpBackendUserFromFixture(1);
69  $this->writeSiteConfiguration(
70  'test',
71  $this->buildSiteConfiguration(1, '/'),
72  [
73  $this->buildDefaultLanguageConfiguration('EN', '/en/'),
74  ],
75  $this->buildErrorHandlingConfiguration('Fluid', [404]),
76  );
77  $_SERVER['HTTP_HOST'] = 'example.com';
78  $_SERVER['REQUEST_URI'] = '/en/';
79  $_GET['id'] = 1;
80  GeneralUtility::flushInternalRuntimeCaches();
81  $site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByIdentifier('test');
82 
83  $this->typoScriptFrontendController = GeneralUtility::makeInstance(
84  TypoScriptFrontendController::class,
85  GeneralUtility::makeInstance(Context::class),
86  $site,
87  $site->getDefaultLanguage(),
88  new ‪PageArguments(1, '0', []),
89  GeneralUtility::makeInstance(FrontendUserAuthentication::class)
90  );
91  $this->typoScriptFrontendController->sys_page = GeneralUtility::makeInstance(PageRepository::class);
92  $this->typoScriptFrontendController->tmpl = GeneralUtility::makeInstance(TemplateService::class);
93  $this->subject = GeneralUtility::makeInstance(ContentObjectRenderer::class, $this->typoScriptFrontendController);
94  $this->subject->setRequest($this->prophesize(ServerRequestInterface::class)->reveal());
95  }
96 
103  public function ‪getQueryDataProvider(): array
104  {
105  return [
106  'testing empty conf' => [
107  'tt_content',
108  [],
109  [
110  'SELECT' => '*',
111  ],
112  ],
113  'testing #17284: adding uid/pid for workspaces' => [
114  'tt_content',
115  [
116  'selectFields' => 'header,bodytext',
117  ],
118  [
119  'SELECT' => 'header,bodytext, [tt_content].[uid] AS [uid], [tt_content].[pid] AS [pid], [tt_content].[t3ver_state] AS [t3ver_state]',
120  ],
121  ],
122  'testing #17284: no need to add' => [
123  'tt_content',
124  [
125  'selectFields' => 'tt_content.*',
126  ],
127  [
128  'SELECT' => 'tt_content.*',
129  ],
130  ],
131  'testing #17284: no need to add #2' => [
132  'tt_content',
133  [
134  'selectFields' => '*',
135  ],
136  [
137  'SELECT' => '*',
138  ],
139  ],
140  'testing #29783: joined tables, prefix tablename' => [
141  'tt_content',
142  [
143  'selectFields' => 'tt_content.header,be_users.username',
144  'join' => 'be_users ON tt_content.cruser_id = be_users.uid',
145  ],
146  [
147  'SELECT' => 'tt_content.header,be_users.username, [tt_content].[uid] AS [uid], [tt_content].[pid] AS [pid], [tt_content].[t3ver_state] AS [t3ver_state]',
148  ],
149  ],
150  'testing #34152: single count(*), add nothing' => [
151  'tt_content',
152  [
153  'selectFields' => 'count(*)',
154  ],
155  [
156  'SELECT' => 'count(*)',
157  ],
158  ],
159  'testing #34152: single max(crdate), add nothing' => [
160  'tt_content',
161  [
162  'selectFields' => 'max(crdate)',
163  ],
164  [
165  'SELECT' => 'max(crdate)',
166  ],
167  ],
168  'testing #34152: single min(crdate), add nothing' => [
169  'tt_content',
170  [
171  'selectFields' => 'min(crdate)',
172  ],
173  [
174  'SELECT' => 'min(crdate)',
175  ],
176  ],
177  'testing #34152: single sum(is_siteroot), add nothing' => [
178  'tt_content',
179  [
180  'selectFields' => 'sum(is_siteroot)',
181  ],
182  [
183  'SELECT' => 'sum(is_siteroot)',
184  ],
185  ],
186  'testing #34152: single avg(crdate), add nothing' => [
187  'tt_content',
188  [
189  'selectFields' => 'avg(crdate)',
190  ],
191  [
192  'SELECT' => 'avg(crdate)',
193  ],
194  ],
195  'single distinct, add nothing' => [
196  'tt_content',
197  [
198  'selectFields' => 'DISTINCT crdate',
199  ],
200  [
201  'SELECT' => 'DISTINCT crdate',
202  ],
203  ],
204  'testing #96321: pidInList=root does not raise PHP 8 warning' => [
205  'tt_content',
206  [
207  'selectFields' => '*',
208  'recursive' => '5',
209  'pidInList' => 'root',
210  ],
211  [
212  'SELECT' => '*',
213  ],
214  ],
215  ];
216  }
217 
227  public function ‪getQuery(string $table, array $conf, array $expected): void
228  {
229  ‪$GLOBALS['TCA'] = [
230  'pages' => [
231  'ctrl' => [
232  'enablecolumns' => [
233  'disabled' => 'hidden',
234  ],
235  ],
236  ],
237  'tt_content' => [
238  'ctrl' => [
239  'enablecolumns' => [
240  'disabled' => 'hidden',
241  ],
242  'versioningWS' => true,
243  ],
244  ],
245  ];
246 
247  $result = $this->subject->getQuery($table, $conf, true);
248 
249  $databasePlatform = (new ConnectionPool())->getConnectionForTable('tt_content')->getDatabasePlatform();
250  foreach ($expected as $field => $value) {
251  // Replace the MySQL backtick quote character with the actual quote character for the DBMS,
252  if (!($databasePlatform instanceof SQLServerPlatform) && $field === 'SELECT') {
253  $quoteChar = $databasePlatform->getIdentifierQuoteCharacter();
254  $value = str_replace(['[', ']'], [$quoteChar, $quoteChar], $value);
255  }
256  self::assertEquals($value, $result[$field]);
257  }
258  }
259 
264  {
265  $this->subject = $this->getAccessibleMock(ContentObjectRenderer::class, ['getTreeList'], [$this->typoScriptFrontendController]);
266  $this->subject->start([], 'tt_content');
267 
268  $conf = [
269  'recursive' => '15',
270  'pidInList' => '16, -35',
271  ];
272 
273  $this->subject->expects(self::exactly(2))
274  ->method('getTreeList')
275  ->withConsecutive([-16, 15], [-35, 15])
276  ->willReturnOnConsecutiveCalls('15,16', '15,35');
277 
278  $this->subject->getQuery('tt_content', $conf, true);
279  }
280 
285  {
286  $this->typoScriptFrontendController->id = 27;
287 
288  $this->subject = $this->getAccessibleMock(ContentObjectRenderer::class, ['getTreeList'], [$this->typoScriptFrontendController]);
289  $this->subject->start([], 'tt_content');
290 
291  $conf = [
292  'pidInList' => 'this',
293  'recursive' => '4',
294  ];
295 
296  $this->subject->expects(self::once())
297  ->method('getTreeList')
298  ->with(-27)
299  ->willReturn('27');
300 
301  $this->subject->getQuery('tt_content', $conf, true);
302  }
303 
307  public function ‪getWhereReturnCorrectQueryDataProvider(): array
308  {
309  return [
310  [
311  [
312  'tt_content' => [
313  'ctrl' => [
314  ],
315  'columns' => [
316  ],
317  ],
318  ],
319  'tt_content',
320  [
321  'uidInList' => '42',
322  'pidInList' => 43,
323  'where' => 'tt_content.cruser_id=5',
324  'groupBy' => 'tt_content.title',
325  'orderBy' => 'tt_content.sorting',
326  ],
327  '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`',
328  ],
329  [
330  [
331  'tt_content' => [
332  'ctrl' => [
333  'delete' => 'deleted',
334  'enablecolumns' => [
335  'disabled' => 'hidden',
336  'starttime' => 'startdate',
337  'endtime' => 'enddate',
338  ],
339  'languageField' => 'sys_language_uid',
340  'transOrigPointerField' => 'l18n_parent',
341  ],
342  'columns' => [
343  ],
344  ],
345  ],
346  'tt_content',
347  [
348  'uidInList' => 42,
349  'pidInList' => 43,
350  'where' => 'tt_content.cruser_id=5',
351  'groupBy' => 'tt_content.title',
352  'orderBy' => 'tt_content.sorting',
353  ],
354  '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`',
355  ],
356  [
357  [
358  'tt_content' => [
359  'ctrl' => [
360  'languageField' => 'sys_language_uid',
361  'transOrigPointerField' => 'l18n_parent',
362  ],
363  'columns' => [
364  ],
365  ],
366  ],
367  'tt_content',
368  [
369  'uidInList' => 42,
370  'pidInList' => 43,
371  'where' => 'tt_content.cruser_id=5',
372  'languageField' => 0,
373  ],
374  'WHERE (`tt_content`.`uid` IN (42)) AND (`tt_content`.`pid` IN (43)) AND (tt_content.cruser_id=5)',
375  ],
376  ];
377  }
378 
382  public function ‪typolinkReturnsCorrectLinkForEmails(): void
383  {
384  $expected = '<a href="mailto:test@example.com">Send me an email</a>';
385  ‪$subject = new ContentObjectRenderer();
386  $result = ‪$subject->typoLink('Send me an email', ['parameter' => 'mailto:test@example.com']);
387  self::assertEquals($expected, $result);
388 
389  $result = ‪$subject->typoLink('Send me an email', ['parameter' => 'test@example.com']);
390  self::assertEquals($expected, $result);
391  }
392 
397  {
398  $tsfe = $this->getMockBuilder(TypoScriptFrontendController::class)->disableOriginalConstructor()->getMock();
399  ‪$subject = new ContentObjectRenderer($tsfe);
400 
401  $tsfe->spamProtectEmailAddresses = 1;
402  $result = ‪$subject->typoLink('Send me an email', ['parameter' => 'mailto:test@example.com']);
403  self::assertEquals('<a href="#" data-mailto-token="nbjmup+uftuAfybnqmf/dpn" data-mailto-vector="1">Send me an email</a>', $result);
404 
405  $tsfe->spamProtectEmailAddresses = 'ascii';
406  $result = ‪$subject->typoLink('Send me an email', ['parameter' => 'mailto:test@example.com']);
407  self::assertEquals('<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#116;&#101;&#115;&#116;&#64;&#101;&#120;&#97;&#109;&#112;&#108;&#101;&#46;&#99;&#111;&#109;">Send me an email</a>', $result);
408  }
409 
414  {
415  $tsfe = $this->getMockBuilder(TypoScriptFrontendController::class)->disableOriginalConstructor()->getMock();
416  ‪$subject = new ContentObjectRenderer($tsfe);
417  ‪$subject->start([], 'tt_content');
418 
419  $expected = '';
420  $actual = ‪$subject->searchWhere('ab', 'header,bodytext', 'tt_content');
421  self::assertEquals($expected, $actual);
422  }
423 
427  public function ‪libParseFuncProperlyKeepsTagsUnescaped(): void
428  {
429  $tsfe = $this->getMockBuilder(TypoScriptFrontendController::class)->disableOriginalConstructor()->getMock();
430  ‪$subject = new ContentObjectRenderer($tsfe);
431  ‪$subject->setRequest($this->prophesize(ServerRequestInterface::class)->reveal());
432  ‪$subject->setLogger(new NullLogger());
433  $input = 'This is a simple inline text, no wrapping configured';
434  $result = ‪$subject->parseFunc($input, $this->‪getLibParseFunc());
435  self::assertEquals($input, $result);
436 
437  $input = '<p>A one liner paragraph</p>';
438  $result = ‪$subject->parseFunc($input, $this->‪getLibParseFunc());
439  self::assertEquals($input, $result);
440 
441  $input = 'A one liner paragraph
442 And another one';
443  $result = ‪$subject->parseFunc($input, $this->‪getLibParseFunc());
444  self::assertEquals($input, $result);
445 
446  $input = '<p>A one liner paragraph</p><p>And another one and the spacing is kept</p>';
447  $result = ‪$subject->parseFunc($input, $this->‪getLibParseFunc());
448  self::assertEquals($input, $result);
449 
450  $input = '<p>text to a <a href="https://www.example.com">an external page</a>.</p>';
451  $result = ‪$subject->parseFunc($input, $this->‪getLibParseFunc());
452  self::assertEquals($input, $result);
453  }
454 
458  protected function ‪getLibParseFunc(): array
459  {
460  return [
461  'htmlSanitize' => '1',
462  'makelinks' => '1',
463  'makelinks.' => [
464  'http.' => [
465  'keep' => '{$styles.content.links.keep}',
466  'extTarget' => '',
467  'mailto.' => [
468  'keep' => 'path',
469  ],
470  ],
471  ],
472  'tags.' => [
473  'link' => 'TEXT',
474  'link.' => [
475  'current' => '1',
476  'typolink.' => [
477  'parameter.' => [
478  'data' => 'parameters : allParams',
479  ],
480  ],
481  'parseFunc.' => [
482  'constants' => '1',
483  ],
484  ],
485  'a' => 'TEXT',
486  'a.' => [
487  'current' => '1',
488  'typolink.' => [
489  'parameter.' => [
490  'data' => 'parameters:href',
491  ],
492  ],
493  ],
494  ],
495 
496  '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',
497  'denyTags' => '*',
498  'sword' => '<span class="csc-sword">|</span>',
499  'constants' => '1',
500  'nonTypoTagStdWrap.' => [
501  'HTMLparser' => '1',
502  'HTMLparser.' => [
503  'keepNonMatchedTags' => '1',
504  'htmlSpecialChars' => '2',
505  ],
506  ],
507  ];
508  }
509 
510  public function ‪checkIfReturnsExpectedValuesDataProvider(): iterable
511  {
512  yield 'isNull returns true if stdWrap returns null' => [
513  'configuration' => [
514  'isNull.' => [
515  'field' => 'unknown',
516  ],
517  ],
518  'expected' => true,
519  ];
520 
521  yield 'isNull returns false if stdWrap returns not null' => [
522  'configuration' => [
523  'isNull.' => [
524  'field' => 'known',
525  ],
526  ],
527  'expected' => false,
528  ];
529  }
530 
535  public function ‪checkIfReturnsExpectedValues(array $configuration, bool $expected): void
536  {
537  $this->subject->data = [
538  'known' => 'somevalue',
539  ];
540  self::assertSame($expected, $this->subject->checkIf($configuration));
541  }
542 
544  {
545  $width = 900;
546  $height = 600;
547  $processingWidth = $width . 'm';
548  $processingHeight = $height . 'm';
549  $defaultConfiguration = [
550  'wrap' => '<a href="javascript:close();"> | </a>',
551  'width' => $processingWidth,
552  'height' => $processingHeight,
553  'JSwindow' => '1',
554  'JSwindow.' => [
555  'newWindow' => '0',
556  ],
557  'crop.' => [
558  'data' => 'file:current:crop',
559  ],
560  'linkParams.' => [
561  'ATagParams.' => [
562  'dataWrap' => 'class="lightbox" rel="lightbox[{field:uid}]"',
563  ],
564  ],
565  'enable' => true,
566  ];
567  $imageTag = '<img class="image-embed-item" src="/fileadmin/_processed_/team-t3board10-processed.jpg" width="500" height="300" loading="lazy" alt="" />';
568  $windowFeatures = 'width=' . $width . ',height=' . $height . ',status=0,menubar=0';
569 
570  $configurationEnableFalse = $defaultConfiguration;
571  $configurationEnableFalse['enable'] = false;
572  yield 'enable => false configuration returns image tag as is.' => [
573  'content' => $imageTag,
574  'configuration' => $configurationEnableFalse,
575  'expected' => [$imageTag => true],
576  ];
577 
578  yield 'image is wrapped with link tag.' => [
579  'content' => $imageTag,
580  'configuration' => $defaultConfiguration,
581  'expected' => [
582  '<a href="index.php?eID=tx_cms_showpic&amp;file=1' => true,
583  $imageTag . '</a>' => true,
584  'data-window-features="' . $windowFeatures => true,
585  'data-window-target="thePicture"' => true,
586  ' target="' . 'thePicture' => true,
587  ],
588  ];
589 
590  $paramsConfiguration = $defaultConfiguration;
591  $windowFeaturesOverrides = 'width=420,status=1,menubar=1,foo=bar';
592  $windowFeaturesOverriddenExpected = 'width=420,height=' . $height . ',status=1,menubar=1,foo=bar';
593  $paramsConfiguration['JSwindow.']['params'] = $windowFeaturesOverrides;
594  yield 'JSWindow.params overrides windowParams' => [
595  'content' => $imageTag,
596  'configuration' => $paramsConfiguration,
597  'expected' => [
598  'data-window-features="' . $windowFeaturesOverriddenExpected => true,
599  ],
600  ];
601 
602  $newWindowConfiguration = $defaultConfiguration;
603  $newWindowConfiguration['JSwindow.']['newWindow'] = '1';
604  yield 'data-window-target is not "thePicture" if newWindow = 1 but an md5 hash of the url.' => [
605  'content' => $imageTag,
606  'configuration' => $newWindowConfiguration,
607  'expected' => [
608  'data-window-target="thePicture' => false,
609  ],
610  ];
611 
612  $newWindowConfiguration = $defaultConfiguration;
613  $newWindowConfiguration['JSwindow.']['expand'] = '20,40';
614  $windowFeaturesExpand = 'width=' . ($width + 20) . ',height=' . ($height + 40) . ',status=0,menubar=0';
615  yield 'expand increases the window size by its value' => [
616  'content' => $imageTag,
617  'configuration' => $newWindowConfiguration,
618  'expected' => [
619  'data-window-features="' . $windowFeaturesExpand => true,
620  ],
621  ];
622 
623  $directImageLinkConfiguration = $defaultConfiguration;
624  $directImageLinkConfiguration['directImageLink'] = '1';
625  yield 'Direct image link does not use eID and links directly to the image.' => [
626  'content' => $imageTag,
627  'configuration' => $directImageLinkConfiguration,
628  'expected' => [
629  'index.php?eID=tx_cms_showpic&amp;file=1' => false,
630  '<a href="fileadmin/_processed_' => true,
631  'data-window-url="fileadmin/_processed_' => true,
632  ],
633  ];
634 
635  // @todo Error: Object of class TYPO3\CMS\Core\Resource\FileReference could not be converted to string
636  // $altUrlConfiguration = $defaultConfiguration;
637  // $altUrlConfiguration['JSwindow.']['altUrl'] = '/alternative-url';
638  // yield 'JSwindow.altUrl forces an alternative url.' => [
639  // 'content' => $imageTag,
640  // 'configuration' => $altUrlConfiguration,
641  // 'expected' => [
642  // '<a href="/alternative-url' => true,
643  // 'data-window-url="/alternative-url' => true,
644  // ],
645  // ];
646 
647  $altUrlConfigurationNoDefault = $defaultConfiguration;
648  $altUrlConfigurationNoDefault['JSwindow.']['altUrl'] = '/alternative-url';
649  $altUrlConfigurationNoDefault['JSwindow.']['altUrl_noDefaultParams'] = '1';
650  yield 'JSwindow.altUrl_noDefaultParams removes the default ?file= params' => [
651  'content' => $imageTag,
652  'configuration' => $altUrlConfigurationNoDefault,
653  'expected' => [
654  '<a href="/alternative-url' => true,
655  'data-window-url="/alternative-url' => true,
656  'data-window-url="/alternative-url?file=' => false,
657  ],
658  ];
659 
660  $targetConfiguration = $defaultConfiguration;
661  $targetConfiguration['target'] = 'myTarget';
662  yield 'Setting target overrides the default target "thePicture.' => [
663  'content' => $imageTag,
664  'configuration' => $targetConfiguration,
665  'expected' => [
666  ' target="myTarget"' => true,
667  'data-window-target="thePicture"' => true,
668  ],
669  ];
670 
671  $parameters = [
672  'sample' => '1',
673  'width' => $processingWidth,
674  'height' => $processingHeight,
675  'effects' => 'gamma=1.3 | flip | rotate=180',
676  'bodyTag' => '<body style="margin:0; background:#fff;">',
677  'title' => 'My Title',
678  'wrap' => '<div class="my-wrap">|</div>',
679  'crop' => '{"default":{"cropArea":{"x":0,"y":0,"width":1,"height":1},"selectedRatio":"NaN","focusArea":null}}',
680  ];
681  $parameterConfiguration = array_replace($defaultConfiguration, $parameters);
682  $expectedParameters = $parameters;
683  $expectedParameters['sample'] = 1;
684  yield 'Setting one of [width, height, effects, bodyTag, title, wrap, crop, sample] will add them to the parameter list.' => [
685  'content' => $imageTag,
686  'configuration' => $parameterConfiguration,
687  'expected' => [],
688  'expectedParams' => $expectedParameters,
689  ];
690 
691  $stdWrapConfiguration = $defaultConfiguration;
692  $stdWrapConfiguration['stdWrap.'] = [
693  'append' => 'TEXT',
694  'append.' => [
695  'value' => 'appendedString',
696  ],
697  ];
698  yield 'stdWrap is called upon the whole content.' => [
699  'content' => $imageTag,
700  'configuration' => $stdWrapConfiguration,
701  'expected' => [
702  'appendedString' => true,
703  ],
704  ];
705  }
706 
711  public function ‪imageLinkWrapWrapsTheContentAsConfigured(string $content, array $configuration, array $expected, array $expectedParams = []): void
712  {
714  $this->importCSVDataSet(__DIR__ . '/DataSet/FileReferences.csv');
715  $fileReferenceData = [
716  'uid' => 1,
717  'uid_local' => 1,
718  'crop' => '{"default":{"cropArea":{"x":0,"y":0,"width":1,"height":1},"selectedRatio":"NaN","focusArea":null}}',
719  ];
720  $fileReference = new FileReference($fileReferenceData);
721  $this->subject->setCurrentFile($fileReference);
722  $result = $this->subject->imageLinkWrap($content, $fileReference, $configuration);
723 
724  foreach ($expected as $expectedString => $shouldContain) {
725  if ($shouldContain) {
726  self::assertStringContainsString($expectedString, $result);
727  } else {
728  self::assertStringNotContainsString($expectedString, $result);
729  }
730  }
731 
732  if ($expectedParams !== []) {
733  preg_match('@href="(.*)"@U', $result, $matches);
734  self::assertArrayHasKey(1, $matches);
735  $url = parse_url(html_entity_decode($matches[1]));
736  parse_str($url['query'], $queryResult);
737  $base64_string = implode('', $queryResult['parameters']);
738  $base64_decoded = base64_decode($base64_string);
739  $jsonDecodedArray = json_decode($base64_decoded, true);
740  self::assertSame($expectedParams, $jsonDecodedArray);
741  }
742  }
743 
748  {
749  $this->importCSVDataSet(__DIR__ . '/DataSet/FileReferences.csv');
750  $fileReferenceData = [
751  'uid' => 1,
752  'uid_local' => 1,
753  'crop' => '{"default":{"cropArea":{"x":0,"y":0,"width":0.5,"height":0.5},"selectedRatio":"NaN","focusArea":null}}',
754  ];
755  $fileReference = new FileReference($fileReferenceData);
756 
757  ‪$subject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
758  $result = ‪$subject->getImgResource($fileReference, []);
759 
760  $expectedWidth = 512;
761  $expectedHeight = 341;
762 
763  self::assertEquals($expectedWidth, $result[0]);
764  self::assertEquals($expectedHeight, $result[1]);
765  }
766 }
‪TYPO3\CMS\Core\Routing\PageArguments
Definition: PageArguments.php:26
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\$pathsToProvideInTestInstance
‪$pathsToProvideInTestInstance
Definition: ContentObjectRendererTest.php:60
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\typolinkReturnsCorrectLinkForEmails
‪typolinkReturnsCorrectLinkForEmails()
Definition: ContentObjectRendererTest.php:379
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\checkIfReturnsExpectedValues
‪checkIfReturnsExpectedValues(array $configuration, bool $expected)
Definition: ContentObjectRendererTest.php:532
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait
Definition: SiteBasedTestTrait.php:36
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\getQueryCallsGetTreeListWithNegativeValuesIfRecursiveIsSet
‪getQueryCallsGetTreeListWithNegativeValuesIfRecursiveIsSet()
Definition: ContentObjectRendererTest.php:260
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\$typoScriptFrontendController
‪TypoScriptFrontendController $typoScriptFrontendController
Definition: ContentObjectRendererTest.php:58
‪TYPO3\CMS\Core\Resource\FileReference
Definition: FileReference.php:33
‪TYPO3\CMS\Core\Site\SiteFinder
Definition: SiteFinder.php:31
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\imageLinkWrapWrapsTheContentAsConfiguredDataProvider
‪imageLinkWrapWrapsTheContentAsConfiguredDataProvider()
Definition: ContentObjectRendererTest.php:540
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\setUp
‪setUp()
Definition: ContentObjectRendererTest.php:62
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\getImgResourceRespectsFileReferenceObjectCropData
‪getImgResourceRespectsFileReferenceObjectCropData()
Definition: ContentObjectRendererTest.php:744
‪TYPO3\CMS\Core\Context\Context
Definition: Context.php:53
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\checkIfReturnsExpectedValuesDataProvider
‪checkIfReturnsExpectedValuesDataProvider()
Definition: ContentObjectRendererTest.php:507
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\getLibParseFunc
‪array getLibParseFunc()
Definition: ContentObjectRendererTest.php:455
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\getQuery
‪getQuery(string $table, array $conf, array $expected)
Definition: ContentObjectRendererTest.php:224
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\typolinkReturnsCorrectLinkForSpamEncryptedEmails
‪typolinkReturnsCorrectLinkForSpamEncryptedEmails()
Definition: ContentObjectRendererTest.php:393
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\getQueryDataProvider
‪array getQueryDataProvider()
Definition: ContentObjectRendererTest.php:100
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest
Definition: ContentObjectRendererTest.php:42
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\LANGUAGE_PRESETS
‪const LANGUAGE_PRESETS
Definition: ContentObjectRendererTest.php:48
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\getWhereReturnCorrectQueryDataProvider
‪array getWhereReturnCorrectQueryDataProvider()
Definition: ContentObjectRendererTest.php:304
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\$subject
‪ContentObjectRenderer $subject
Definition: ContentObjectRendererTest.php:54
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\libParseFuncProperlyKeepsTagsUnescaped
‪libParseFuncProperlyKeepsTagsUnescaped()
Definition: ContentObjectRendererTest.php:424
‪TYPO3\CMS\Core\TypoScript\TemplateService
Definition: TemplateService.php:46
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
Definition: TypoScriptFrontendController.php:104
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\searchWhereWithTooShortSearchWordWillReturnValidWhereStatement
‪searchWhereWithTooShortSearchWordWillReturnValidWhereStatement()
Definition: ContentObjectRendererTest.php:410
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\getQueryCallsGetTreeListWithCurrentPageIfThisIsSet
‪getQueryCallsGetTreeListWithCurrentPageIfThisIsSet()
Definition: ContentObjectRendererTest.php:281
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\ContentObjectRendererTest\imageLinkWrapWrapsTheContentAsConfigured
‪imageLinkWrapWrapsTheContentAsConfigured(string $content, array $configuration, array $expected, array $expectedParams=[])
Definition: ContentObjectRendererTest.php:708
‪TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication
Definition: FrontendUserAuthentication.php:32
‪TYPO3\CMS\Core\Domain\Repository\PageRepository
Definition: PageRepository.php:53
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject
Definition: ContentObjectRendererTest.php:18
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50