‪TYPO3CMS  9.5
HtmlentitiesDecodeViewHelperTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
19 
23 class ‪HtmlentitiesDecodeViewHelperTest extends ViewHelperBaseTestcase
24 {
28  protected ‪$viewHelper;
29 
36 
37  protected function ‪setUp()
38  {
39  parent::setUp();
40  $this->viewHelper = new ‪HtmlentitiesDecodeViewHelper();
41  $this->injectDependenciesIntoViewHelper($this->viewHelper);
42  }
43 
48  {
49  $this->setArgumentsUnderTest(
50  $this->viewHelper,
51  [
52  'value' => 'Some string'
53  ]
54  );
55  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
56  $this->assertEquals('Some string', $actualResult);
57  }
58 
63  {
64  $this->viewHelper->setRenderChildrenClosure(
65  function () {
66  return 'Some string';
67  }
68  );
69  $this->setArgumentsUnderTest($this->viewHelper);
70  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
71  $this->assertEquals('Some string', $actualResult);
72  }
73 
78  {
79  $source = 'This is a sample text without special characters. <> &©"\'';
80  $this->setArgumentsUnderTest(
81  $this->viewHelper,
82  [
83  'value' => $source,
84  ]
85  );
86  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
87  $this->assertSame($source, $actualResult);
88  }
89 
93  public function ‪renderDecodesSimpleString()
94  {
95  $source = 'Some special characters: &amp; &quot; \' &lt; &gt; *';
96  $expectedResult = 'Some special characters: & " \' < > *';
97  $this->setArgumentsUnderTest(
98  $this->viewHelper,
99  [
100  'value' => $source
101  ]
102  );
103  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
104  $this->assertEquals($expectedResult, $actualResult);
105  }
106 
110  public function ‪renderRespectsKeepQuoteArgument()
111  {
112  $source = 'Some special characters: &amp; &quot; \' &lt; &gt; *';
113  $expectedResult = 'Some special characters: & &quot; \' < > *';
114  $this->setArgumentsUnderTest(
115  $this->viewHelper,
116  [
117  'value' => $source,
118  'keepQuotes' => true,
119  ]
120  );
121  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
122  $this->assertEquals($expectedResult, $actualResult);
123  }
124 
128  public function ‪renderRespectsEncodingArgument()
129  {
130  $source = utf8_decode('Some special characters: &amp; &quot; \' &lt; &gt; *');
131  $expectedResult = 'Some special characters: & " \' < > *';
132  $this->setArgumentsUnderTest(
133  $this->viewHelper,
134  [
135  'value' => $source,
136  'encoding' => 'ISO-8859-1',
137  ]
138  );
139  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
140  $this->assertEquals($expectedResult, $actualResult);
141  }
142 
147  {
148  $source = new \stdClass();
149  $this->setArgumentsUnderTest(
150  $this->viewHelper,
151  [
152  'value' => $source
153  ]
154  );
155  $actualResult = $this->viewHelper->render();
156  $this->assertSame($source, $actualResult);
157  }
158 }
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\HtmlentitiesDecodeViewHelperTest\$viewHelper
‪HtmlentitiesDecodeViewHelper $viewHelper
Definition: HtmlentitiesDecodeViewHelperTest.php:27
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\HtmlentitiesDecodeViewHelperTest\renderUsesChildnodesAsSourceIfSpecified
‪renderUsesChildnodesAsSourceIfSpecified()
Definition: HtmlentitiesDecodeViewHelperTest.php:60
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\HtmlentitiesDecodeViewHelperTest\setUp
‪setUp()
Definition: HtmlentitiesDecodeViewHelperTest.php:35
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlentitiesDecodeViewHelper
Definition: HtmlentitiesDecodeViewHelper.php:50
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\HtmlentitiesDecodeViewHelperTest
Definition: HtmlentitiesDecodeViewHelperTest.php:24
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\HtmlentitiesDecodeViewHelperTest\renderDoesNotModifyValueIfItDoesNotContainSpecialCharacters
‪renderDoesNotModifyValueIfItDoesNotContainSpecialCharacters()
Definition: HtmlentitiesDecodeViewHelperTest.php:75
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\HtmlentitiesDecodeViewHelperTest\renderReturnsUnmodifiedSourceIfItIsNoString
‪renderReturnsUnmodifiedSourceIfItIsNoString()
Definition: HtmlentitiesDecodeViewHelperTest.php:144
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\HtmlentitiesDecodeViewHelperTest\$defaultArguments
‪array $defaultArguments
Definition: HtmlentitiesDecodeViewHelperTest.php:33
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format
Definition: BytesViewHelperTest.php:2
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\HtmlentitiesDecodeViewHelperTest\renderRespectsEncodingArgument
‪renderRespectsEncodingArgument()
Definition: HtmlentitiesDecodeViewHelperTest.php:126
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\HtmlentitiesDecodeViewHelperTest\renderUsesValueAsSourceIfSpecified
‪renderUsesValueAsSourceIfSpecified()
Definition: HtmlentitiesDecodeViewHelperTest.php:45
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\HtmlentitiesDecodeViewHelperTest\renderDecodesSimpleString
‪renderDecodesSimpleString()
Definition: HtmlentitiesDecodeViewHelperTest.php:91
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\HtmlentitiesDecodeViewHelperTest\renderRespectsKeepQuoteArgument
‪renderRespectsKeepQuoteArgument()
Definition: HtmlentitiesDecodeViewHelperTest.php:108