‪TYPO3CMS  9.5
EscapeChildrenRenderingTest.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\Core\Functional\FunctionalTestCase;
19 
20 class ‪EscapeChildrenRenderingTest extends FunctionalTestCase
21 {
22  protected ‪$testExtensionsToLoad = ['typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test'];
23 
24  protected ‪$coreExtensionsToLoad = ['fluid'];
25 
27  {
28  return [
29  'EscapeChildrenEnabledAndEscapeOutputDisabled: Tag syntax with children, properly encodes variable value' =>
30  [
31  '<ft:escapeChildrenEnabledAndEscapeOutputDisabled>{settings.test}</ft:escapeChildrenEnabledAndEscapeOutputDisabled>',
32  '&lt;strong&gt;Bla&lt;/strong&gt;'
33  ],
34  'EscapeChildrenEnabledAndEscapeOutputDisabled: Inline syntax with children, properly encodes variable value' =>
35  [
36  '{settings.test -> ft:escapeChildrenEnabledAndEscapeOutputDisabled()}',
37  '&lt;strong&gt;Bla&lt;/strong&gt;'
38  ],
39  'EscapeChildrenEnabledAndEscapeOutputDisabled: Tag syntax with argument, does not encode variable value' =>
40  [
41  '<ft:escapeChildrenEnabledAndEscapeOutputDisabled content="{settings.test}" />',
42  '<strong>Bla</strong>'
43  ],
44  'EscapeChildrenEnabledAndEscapeOutputDisabled: Inline syntax with argument, does not encode variable value' =>
45  [
46  '{ft:escapeChildrenEnabledAndEscapeOutputDisabled(content: settings.test)}',
47  '<strong>Bla</strong>'
48  ],
49  'EscapeChildrenEnabledAndEscapeOutputDisabled: Inline syntax with string, does not encode string value' =>
50  [
51  '{ft:escapeChildrenEnabledAndEscapeOutputDisabled(content: \'<strong>Bla</strong>\')}',
52  '<strong>Bla</strong>'
53  ],
54  'EscapeChildrenEnabledAndEscapeOutputDisabled: Inline syntax with argument in quotes, does not encode variable value' =>
55  [
56  '{ft:escapeChildrenEnabledAndEscapeOutputDisabled(content: \'{settings.test}\')}',
57  '<strong>Bla</strong>'
58  ],
59  'EscapeChildrenEnabledAndEscapeOutputDisabled: Tag syntax with nested inline syntax and children rendering, does not encode variable value' =>
60  [
61  '<ft:escapeChildrenEnabledAndEscapeOutputDisabled content="{settings.test -> ft:escapeChildrenEnabledAndEscapeOutputDisabled()}" />',
62  '<strong>Bla</strong>'
63  ],
64  'EscapeChildrenEnabledAndEscapeOutputDisabled: Tag syntax with nested inline syntax and argument in inline, does not encode variable value' =>
65  [
66  '<ft:escapeChildrenEnabledAndEscapeOutputDisabled content="{ft:escapeChildrenEnabledAndEscapeOutputDisabled(content: settings.test)}" />',
67  '<strong>Bla</strong>'
68  ],
69 
70  'EscapeChildrenDisabledAndEscapeOutputDisabled: Tag syntax with children, properly encodes variable value' =>
71  [
72  '<ft:escapeChildrenDisabledAndEscapeOutputDisabled>{settings.test}</ft:escapeChildrenDisabledAndEscapeOutputDisabled>',
73  '<strong>Bla</strong>'
74  ],
75  'EscapeChildrenDisabledAndEscapeOutputDisabled: Inline syntax with children, properly encodes variable value' =>
76  [
77  '{settings.test -> ft:escapeChildrenDisabledAndEscapeOutputDisabled()}',
78  '<strong>Bla</strong>'
79  ],
80  'EscapeChildrenDisabledAndEscapeOutputDisabled: Tag syntax with argument, does not encode variable value' =>
81  [
82  '<ft:escapeChildrenDisabledAndEscapeOutputDisabled content="{settings.test}" />',
83  '<strong>Bla</strong>'
84  ],
85  'EscapeChildrenDisabledAndEscapeOutputDisabled: Inline syntax with argument, does not encode variable value' =>
86  [
87  '{ft:escapeChildrenDisabledAndEscapeOutputDisabled(content: settings.test)}',
88  '<strong>Bla</strong>'
89  ],
90  'EscapeChildrenDisabledAndEscapeOutputDisabled: Inline syntax with string, does not encode string value' =>
91  [
92  '{ft:escapeChildrenDisabledAndEscapeOutputDisabled(content: \'<strong>Bla</strong>\')}',
93  '<strong>Bla</strong>'
94  ],
95  'EscapeChildrenDisabledAndEscapeOutputDisabled: Inline syntax with argument in quotes, does not encode variable value' =>
96  [
97  '{ft:escapeChildrenDisabledAndEscapeOutputDisabled(content: \'{settings.test}\')}',
98  '<strong>Bla</strong>'
99  ],
100  'EscapeChildrenDisabledAndEscapeOutputDisabled: Tag syntax with nested inline syntax and children rendering, does not encode variable value' =>
101  [
102  '<ft:escapeChildrenDisabledAndEscapeOutputDisabled content="{settings.test -> ft:escapeChildrenDisabledAndEscapeOutputDisabled()}" />',
103  '<strong>Bla</strong>'
104  ],
105  'EscapeChildrenDisabledAndEscapeOutputDisabled: Tag syntax with nested inline syntax and argument in inline, does not encode variable value' =>
106  [
107  '<ft:escapeChildrenDisabledAndEscapeOutputDisabled content="{ft:escapeChildrenDisabledAndEscapeOutputDisabled(content: settings.test)}" />',
108  '<strong>Bla</strong>'
109  ],
110 
111  ];
112  }
113 
121  public function ‪renderingTest($viewHelperTemplate, $expectedOutput)
122  {
123  $view = new ‪TemplateView();
124  $view->assign('settings', ['test' => '<strong>Bla</strong>']);
125  $view->getRenderingContext()->getViewHelperResolver()->addNamespace('ft', 'TYPO3Fluid\\FluidTest\\ViewHelpers');
126  $view->getRenderingContext()->getTemplatePaths()->setTemplateSource($viewHelperTemplate);
127 
128  $this->assertSame($expectedOutput, $view->render());
129  }
130 }
‪TYPO3\CMS\Fluid\Tests\Functional
Definition: EscapeChildrenRenderingStandaloneTest.php:2
‪TYPO3\CMS\Fluid\Tests\Functional\EscapeChildrenRenderingTest
Definition: EscapeChildrenRenderingTest.php:21
‪TYPO3\CMS\Fluid\Tests\Functional\EscapeChildrenRenderingTest\renderingTest
‪renderingTest($viewHelperTemplate, $expectedOutput)
Definition: EscapeChildrenRenderingTest.php:121
‪TYPO3\CMS\Fluid\Tests\Functional\EscapeChildrenRenderingTest\$testExtensionsToLoad
‪$testExtensionsToLoad
Definition: EscapeChildrenRenderingTest.php:22
‪TYPO3\CMS\Fluid\Tests\Functional\EscapeChildrenRenderingTest\$coreExtensionsToLoad
‪$coreExtensionsToLoad
Definition: EscapeChildrenRenderingTest.php:24
‪TYPO3\CMS\Fluid\View\TemplateView
Definition: TemplateView.php:24
‪TYPO3\CMS\Fluid\Tests\Functional\EscapeChildrenRenderingTest\viewHelperTemplateSourcesDataProvider
‪viewHelperTemplateSourcesDataProvider()
Definition: EscapeChildrenRenderingTest.php:26