‪TYPO3CMS  11.5
HtmlViewHelperTest.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 
22 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
23 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
24 
25 class ‪HtmlViewHelperTest extends FunctionalTestCase
26 {
28 
32  protected const ‪LANGUAGE_PRESETS = [
33  'EN' => ['id' => 0, 'title' => 'English', 'locale' => 'en_US.UTF8'],
34  ];
35 
36  public function ‪contentIsRenderedDataProvider(): array
37  {
38  return [
39  'format.html: process lib.parseFunc_RTE by default' => [
40  '<f:format.html>###PROJECT### is a cool CMS</f:format.html>',
41  'TYPO3 is a cool CMS',
42  ],
43  'format.html: process inline notation with undefined variable returns empty string' => [
44  '{undefinedVariable -> f:format.html()}',
45  '',
46  ],
47  'format.html: process specific TS path' => [
48  '<f:format.html parseFuncTSPath="lib.foo">###FOO### is BAR</f:format.html>',
49  'BAR is BAR',
50  ],
51  // table attribute is hard to test. It was only used as parent for CONTENT and RECORD cObj.
52  // Further the table will be used in FILES cObj as fallback, if a table was not given in references array.
53  ];
54  }
55 
60  public function ‪contentIsRendered(string $fluidTemplateSource, string $expected): void
61  {
62  $this->importCSVDataSet(__DIR__ . '/../../Fixtures/pages.csv');
64  'test',
65  $this->‪buildSiteConfiguration(1, '/'),
66  [
67  $this->‪buildDefaultLanguageConfiguration('EN', '/en/'),
68  ]
69  );
70  $this->‪createTypoScriptTemplate($fluidTemplateSource);
71 
72  $response = $this->executeFrontendSubRequest(
73  (new InternalRequest())->withPageId(1)
74  );
75  self::assertStringContainsString($expected, (string)$response->getBody());
76  }
77 
78  private function ‪createTypoScriptTemplate(string $fluidTemplateSource): void
79  {
80  (new ‪ConnectionPool())->getConnectionForTable('sys_template')
81  ->insert(
82  'sys_template',
83  [
84  'pid' => 1,
85  'root' => 1,
86  'clear' => 1,
87  'config' => <<<EOT
88 constants.PROJECT = ‪TYPO3
89 constants.FOO = BAR
90 lib.parseFunc_RTE {
91  htmlSanitize = 1
92  constants = 1
93 }
94 lib.foo {
95  htmlSanitize = 1
96  constants = 1
97 }
98 lib.inventor {
99  htmlSanitize = 1
100  plainTextStdWrap.noTrimWrap = || |
101  plainTextStdWrap.dataWrap = |{CURRENT:1}
102 }
103 lib.record {
104  htmlSanitize = 1
105  plainTextStdWrap.noTrimWrap = || |
106  plainTextStdWrap.dataWrap = |{FIELD:title}
107 }
108 lib.news {
109  htmlSanitize = 1
110  constants = 1
111  plainTextStdWrap.noTrimWrap = || |
112  plainTextStdWrap.dataWrap = |{CURRENT:1}
113 }
114 page = PAGE
115 page.10 = FLUIDTEMPLATE
116 page.10 {
117  template = TEXT
118  template.value = $fluidTemplateSource
119 }
120 EOT
121  ]
122  );
123  }
124 }
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format\HtmlViewHelperTest
Definition: HtmlViewHelperTest.php:26
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait
Definition: SiteBasedTestTrait.php:36
‪TYPO3
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format\HtmlViewHelperTest\LANGUAGE_PRESETS
‪const LANGUAGE_PRESETS
Definition: HtmlViewHelperTest.php:31
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\writeSiteConfiguration
‪writeSiteConfiguration(string $identifier, array $site=[], array $languages=[], array $errorHandling=[])
Definition: SiteBasedTestTrait.php:58
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format
Definition: BytesViewHelperTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildDefaultLanguageConfiguration
‪array buildDefaultLanguageConfiguration(string $identifier, string $base)
Definition: SiteBasedTestTrait.php:126
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format\HtmlViewHelperTest\createTypoScriptTemplate
‪createTypoScriptTemplate(string $fluidTemplateSource)
Definition: HtmlViewHelperTest.php:77
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format\HtmlViewHelperTest\contentIsRendered
‪contentIsRendered(string $fluidTemplateSource, string $expected)
Definition: HtmlViewHelperTest.php:59
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪array buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:111
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format\HtmlViewHelperTest\contentIsRenderedDataProvider
‪contentIsRenderedDataProvider()
Definition: HtmlViewHelperTest.php:35