‪TYPO3CMS  10.4
EscapeChildrenRenderingTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
20 
21 class ‪EscapeChildrenRenderingTest extends FunctionalTestCase
22 {
23  protected ‪$testExtensionsToLoad = ['typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test'];
24 
25  protected ‪$coreExtensionsToLoad = ['fluid'];
26 
28  {
29  return [
30  'EscapeChildrenEnabledAndEscapeOutputDisabled: Tag syntax with children, properly encodes variable value' =>
31  [
32  '<ft:escapeChildrenEnabledAndEscapeOutputDisabled>{settings.test}</ft:escapeChildrenEnabledAndEscapeOutputDisabled>',
33  '&lt;strong&gt;Bla&lt;/strong&gt;'
34  ],
35  'EscapeChildrenEnabledAndEscapeOutputDisabled: Inline syntax with children, properly encodes variable value' =>
36  [
37  '{settings.test -> ft:escapeChildrenEnabledAndEscapeOutputDisabled()}',
38  '&lt;strong&gt;Bla&lt;/strong&gt;'
39  ],
40  'EscapeChildrenEnabledAndEscapeOutputDisabled: Tag syntax with argument, does not encode variable value' =>
41  [
42  '<ft:escapeChildrenEnabledAndEscapeOutputDisabled content="{settings.test}" />',
43  '<strong>Bla</strong>'
44  ],
45  'EscapeChildrenEnabledAndEscapeOutputDisabled: Inline syntax with argument, does not encode variable value' =>
46  [
47  '{ft:escapeChildrenEnabledAndEscapeOutputDisabled(content: settings.test)}',
48  '<strong>Bla</strong>'
49  ],
50  'EscapeChildrenEnabledAndEscapeOutputDisabled: Inline syntax with string, does not encode string value' =>
51  [
52  '{ft:escapeChildrenEnabledAndEscapeOutputDisabled(content: \'<strong>Bla</strong>\')}',
53  '<strong>Bla</strong>'
54  ],
55  'EscapeChildrenEnabledAndEscapeOutputDisabled: Inline syntax with argument in quotes, does not encode variable value' =>
56  [
57  '{ft:escapeChildrenEnabledAndEscapeOutputDisabled(content: \'{settings.test}\')}',
58  '<strong>Bla</strong>'
59  ],
60  'EscapeChildrenEnabledAndEscapeOutputDisabled: Tag syntax with nested inline syntax and children rendering, does not encode variable value' =>
61  [
62  '<ft:escapeChildrenEnabledAndEscapeOutputDisabled content="{settings.test -> ft:escapeChildrenEnabledAndEscapeOutputDisabled()}" />',
63  '<strong>Bla</strong>'
64  ],
65  'EscapeChildrenEnabledAndEscapeOutputDisabled: Tag syntax with nested inline syntax and argument in inline, does not encode variable value' =>
66  [
67  '<ft:escapeChildrenEnabledAndEscapeOutputDisabled content="{ft:escapeChildrenEnabledAndEscapeOutputDisabled(content: settings.test)}" />',
68  '<strong>Bla</strong>'
69  ],
70 
71  'EscapeChildrenDisabledAndEscapeOutputDisabled: Tag syntax with children, properly encodes variable value' =>
72  [
73  '<ft:escapeChildrenDisabledAndEscapeOutputDisabled>{settings.test}</ft:escapeChildrenDisabledAndEscapeOutputDisabled>',
74  '<strong>Bla</strong>'
75  ],
76  'EscapeChildrenDisabledAndEscapeOutputDisabled: Inline syntax with children, properly encodes variable value' =>
77  [
78  '{settings.test -> ft:escapeChildrenDisabledAndEscapeOutputDisabled()}',
79  '<strong>Bla</strong>'
80  ],
81  'EscapeChildrenDisabledAndEscapeOutputDisabled: Tag syntax with argument, does not encode variable value' =>
82  [
83  '<ft:escapeChildrenDisabledAndEscapeOutputDisabled content="{settings.test}" />',
84  '<strong>Bla</strong>'
85  ],
86  'EscapeChildrenDisabledAndEscapeOutputDisabled: Inline syntax with argument, does not encode variable value' =>
87  [
88  '{ft:escapeChildrenDisabledAndEscapeOutputDisabled(content: settings.test)}',
89  '<strong>Bla</strong>'
90  ],
91  'EscapeChildrenDisabledAndEscapeOutputDisabled: Inline syntax with string, does not encode string value' =>
92  [
93  '{ft:escapeChildrenDisabledAndEscapeOutputDisabled(content: \'<strong>Bla</strong>\')}',
94  '<strong>Bla</strong>'
95  ],
96  'EscapeChildrenDisabledAndEscapeOutputDisabled: Inline syntax with argument in quotes, does not encode variable value' =>
97  [
98  '{ft:escapeChildrenDisabledAndEscapeOutputDisabled(content: \'{settings.test}\')}',
99  '<strong>Bla</strong>'
100  ],
101  'EscapeChildrenDisabledAndEscapeOutputDisabled: Tag syntax with nested inline syntax and children rendering, does not encode variable value' =>
102  [
103  '<ft:escapeChildrenDisabledAndEscapeOutputDisabled content="{settings.test -> ft:escapeChildrenDisabledAndEscapeOutputDisabled()}" />',
104  '<strong>Bla</strong>'
105  ],
106  'EscapeChildrenDisabledAndEscapeOutputDisabled: Tag syntax with nested inline syntax and argument in inline, does not encode variable value' =>
107  [
108  '<ft:escapeChildrenDisabledAndEscapeOutputDisabled content="{ft:escapeChildrenDisabledAndEscapeOutputDisabled(content: settings.test)}" />',
109  '<strong>Bla</strong>'
110  ],
111 
112  ];
113  }
114 
122  public function ‪renderingTest($viewHelperTemplate, $expectedOutput)
123  {
124  $view = new ‪TemplateView();
125  $view->assign('settings', ['test' => '<strong>Bla</strong>']);
126  $view->getRenderingContext()->getViewHelperResolver()->addNamespace('ft', 'TYPO3Fluid\\FluidTest\\ViewHelpers');
127  $view->getRenderingContext()->getTemplatePaths()->setTemplateSource($viewHelperTemplate);
128 
129  self::assertSame($expectedOutput, $view->render());
130  }
131 }
‪TYPO3\CMS\Fluid\Tests\Functional
Definition: EscapeChildrenRenderingStandaloneTest.php:16
‪TYPO3\CMS\Fluid\Tests\Functional\EscapeChildrenRenderingTest
Definition: EscapeChildrenRenderingTest.php:22
‪TYPO3\CMS\Fluid\Tests\Functional\EscapeChildrenRenderingTest\renderingTest
‪renderingTest($viewHelperTemplate, $expectedOutput)
Definition: EscapeChildrenRenderingTest.php:122
‪TYPO3\CMS\Fluid\Tests\Functional\EscapeChildrenRenderingTest\$testExtensionsToLoad
‪$testExtensionsToLoad
Definition: EscapeChildrenRenderingTest.php:23
‪TYPO3\CMS\Fluid\Tests\Functional\EscapeChildrenRenderingTest\$coreExtensionsToLoad
‪$coreExtensionsToLoad
Definition: EscapeChildrenRenderingTest.php:25
‪TYPO3\CMS\Fluid\View\TemplateView
Definition: TemplateView.php:25
‪TYPO3\CMS\Fluid\Tests\Functional\EscapeChildrenRenderingTest\viewHelperTemplateSourcesDataProvider
‪viewHelperTemplateSourcesDataProvider()
Definition: EscapeChildrenRenderingTest.php:27