‪TYPO3CMS  ‪main
HtmlentitiesDecodeViewHelperTest.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 PHPUnit\Framework\Attributes\Test;
22 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
23 use TYPO3Fluid\Fluid\View\TemplateView;
24 
25 final class ‪HtmlentitiesDecodeViewHelperTest extends FunctionalTestCase
26 {
27  protected bool ‪$initializeDatabase = false;
28 
29  #[Test]
30  public function ‪renderUsesValueAsSourceIfSpecified(): void
31  {
32  $context = $this->get(RenderingContextFactory::class)->create();
33  $context->getTemplatePaths()->setTemplateSource('<f:format.htmlentitiesDecode value="Some string" />');
34  self::assertEquals('Some string', (new TemplateView($context))->render());
35  }
36 
37  #[Test]
39  {
40  $context = $this->get(RenderingContextFactory::class)->create();
41  $context->getTemplatePaths()->setTemplateSource('<f:format.htmlentitiesDecode>Some string</f:format.htmlentitiesDecode>');
42  self::assertEquals('Some string', (new TemplateView($context))->render());
43  }
44 
45  #[Test]
47  {
48  $source = 'This is a sample text without special characters. <> &©"\'';
49  $context = $this->get(RenderingContextFactory::class)->create();
50  $context->getTemplatePaths()->setTemplateSource('<f:format.htmlentitiesDecode>' . $source . '</f:format.htmlentitiesDecode>');
51  self::assertEquals($source, (new TemplateView($context))->render());
52  }
53 
54  #[Test]
55  public function ‪renderDecodesSimpleString(): void
56  {
57  $source = 'Some special characters: &amp; &quot; \' &lt; &gt; *';
58  $expectedResult = 'Some special characters: & " \' < > *';
59  $context = $this->get(RenderingContextFactory::class)->create();
60  $context->getTemplatePaths()->setTemplateSource('<f:format.htmlentitiesDecode>' . $source . '</f:format.htmlentitiesDecode>');
61  self::assertEquals($expectedResult, (new TemplateView($context))->render());
62  }
63 
64  #[Test]
65  public function ‪renderRespectsKeepQuoteArgument(): void
66  {
67  $source = 'Some special characters: &amp; &quot; \' &lt; &gt; *';
68  $expectedResult = 'Some special characters: & &quot; \' < > *';
69  $context = $this->get(RenderingContextFactory::class)->create();
70  $context->getTemplatePaths()->setTemplateSource('<f:format.htmlentitiesDecode keepQuotes="true">' . $source . '</f:format.htmlentitiesDecode>');
71  self::assertEquals($expectedResult, (new TemplateView($context))->render());
72  }
73 
74  #[Test]
75  public function ‪renderRespectsEncodingArgument(): void
76  {
77  $source = 'Some special characters: &amp; &quot; \' &lt; &gt; *';
78  $expectedResult = 'Some special characters: & " \' < > *';
79  $context = $this->get(RenderingContextFactory::class)->create();
80  $context->getTemplatePaths()->setTemplateSource('<f:format.htmlentitiesDecode encoding="ISO-8859-1">' . $source . '</f:format.htmlentitiesDecode>');
81  self::assertEquals($expectedResult, (new TemplateView($context))->render());
82  }
83 }
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format\HtmlentitiesDecodeViewHelperTest\renderRespectsEncodingArgument
‪renderRespectsEncodingArgument()
Definition: HtmlentitiesDecodeViewHelperTest.php:75
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format\HtmlentitiesDecodeViewHelperTest\renderDecodesSimpleString
‪renderDecodesSimpleString()
Definition: HtmlentitiesDecodeViewHelperTest.php:55
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format\HtmlentitiesDecodeViewHelperTest
Definition: HtmlentitiesDecodeViewHelperTest.php:26
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format\HtmlentitiesDecodeViewHelperTest\renderDoesNotModifyValueIfItDoesNotContainSpecialCharacters
‪renderDoesNotModifyValueIfItDoesNotContainSpecialCharacters()
Definition: HtmlentitiesDecodeViewHelperTest.php:46
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format\HtmlentitiesDecodeViewHelperTest\renderUsesChildnodesAsSourceIfSpecified
‪renderUsesChildnodesAsSourceIfSpecified()
Definition: HtmlentitiesDecodeViewHelperTest.php:38
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format
Definition: BytesViewHelperTest.php:18
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format\HtmlentitiesDecodeViewHelperTest\$initializeDatabase
‪bool $initializeDatabase
Definition: HtmlentitiesDecodeViewHelperTest.php:27
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format\HtmlentitiesDecodeViewHelperTest\renderUsesValueAsSourceIfSpecified
‪renderUsesValueAsSourceIfSpecified()
Definition: HtmlentitiesDecodeViewHelperTest.php:30
‪TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory
Definition: RenderingContextFactory.php:51
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format\HtmlentitiesDecodeViewHelperTest\renderRespectsKeepQuoteArgument
‪renderRespectsKeepQuoteArgument()
Definition: HtmlentitiesDecodeViewHelperTest.php:65