TYPO3 CMS  TYPO3_8-7
EscapeChildrenRenderingTest.php
Go to the documentation of this file.
1 <?php
3 
5 
6 class EscapeChildrenRenderingTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
7 {
8  protected $testExtensionsToLoad = ['typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test'];
9 
10  protected $coreExtensionsToLoad = ['fluid'];
11 
13  {
14  return [
15  'EscapeChildrenEnabledAndEscapeOutputDisabled: Tag syntax with children, properly encodes variable value' =>
16  [
17  '<ft:escapeChildrenEnabledAndEscapeOutputDisabled>{settings.test}</ft:escapeChildrenEnabledAndEscapeOutputDisabled>',
18  '&lt;strong&gt;Bla&lt;/strong&gt;'
19  ],
20  'EscapeChildrenEnabledAndEscapeOutputDisabled: Inline syntax with children, properly encodes variable value' =>
21  [
22  '{settings.test -> ft:escapeChildrenEnabledAndEscapeOutputDisabled()}',
23  '&lt;strong&gt;Bla&lt;/strong&gt;'
24  ],
25  'EscapeChildrenEnabledAndEscapeOutputDisabled: Tag syntax with argument, does not encode variable value' =>
26  [
27  '<ft:escapeChildrenEnabledAndEscapeOutputDisabled content="{settings.test}" />',
28  '<strong>Bla</strong>'
29  ],
30  'EscapeChildrenEnabledAndEscapeOutputDisabled: Inline syntax with argument, does not encode variable value' =>
31  [
32  '{ft:escapeChildrenEnabledAndEscapeOutputDisabled(content: settings.test)}',
33  '<strong>Bla</strong>'
34  ],
35  'EscapeChildrenEnabledAndEscapeOutputDisabled: Inline syntax with string, does not encode string value' =>
36  [
37  '{ft:escapeChildrenEnabledAndEscapeOutputDisabled(content: \'<strong>Bla</strong>\')}',
38  '<strong>Bla</strong>'
39  ],
40  'EscapeChildrenEnabledAndEscapeOutputDisabled: Inline syntax with argument in quotes, does encode variable value (encoded before passed to VH)' =>
41  [
42  '{ft:escapeChildrenEnabledAndEscapeOutputDisabled(content: \'{settings.test}\')}',
43  '&lt;strong&gt;Bla&lt;/strong&gt;'
44  ],
45  'EscapeChildrenEnabledAndEscapeOutputDisabled: Tag syntax with nested inline syntax and children rendering, does not encode variable value' =>
46  [
47  '<ft:escapeChildrenEnabledAndEscapeOutputDisabled content="{settings.test -> ft:escapeChildrenEnabledAndEscapeOutputDisabled()}" />',
48  '<strong>Bla</strong>'
49  ],
50  'EscapeChildrenEnabledAndEscapeOutputDisabled: Tag syntax with nested inline syntax and argument in inline, does not encode variable value' =>
51  [
52  '<ft:escapeChildrenEnabledAndEscapeOutputDisabled content="{ft:escapeChildrenEnabledAndEscapeOutputDisabled(content: settings.test)}" />',
53  '<strong>Bla</strong>'
54  ],
55 
56  'EscapeChildrenDisabledAndEscapeOutputDisabled: Tag syntax with children, properly encodes variable value' =>
57  [
58  '<ft:escapeChildrenDisabledAndEscapeOutputDisabled>{settings.test}</ft:escapeChildrenDisabledAndEscapeOutputDisabled>',
59  '<strong>Bla</strong>'
60  ],
61  'EscapeChildrenDisabledAndEscapeOutputDisabled: Inline syntax with children, properly encodes variable value' =>
62  [
63  '{settings.test -> ft:escapeChildrenDisabledAndEscapeOutputDisabled()}',
64  '<strong>Bla</strong>'
65  ],
66  'EscapeChildrenDisabledAndEscapeOutputDisabled: Tag syntax with argument, does not encode variable value' =>
67  [
68  '<ft:escapeChildrenDisabledAndEscapeOutputDisabled content="{settings.test}" />',
69  '<strong>Bla</strong>'
70  ],
71  'EscapeChildrenDisabledAndEscapeOutputDisabled: Inline syntax with argument, does not encode variable value' =>
72  [
73  '{ft:escapeChildrenDisabledAndEscapeOutputDisabled(content: settings.test)}',
74  '<strong>Bla</strong>'
75  ],
76  'EscapeChildrenDisabledAndEscapeOutputDisabled: Inline syntax with string, does not encode string value' =>
77  [
78  '{ft:escapeChildrenDisabledAndEscapeOutputDisabled(content: \'<strong>Bla</strong>\')}',
79  '<strong>Bla</strong>'
80  ],
81  'EscapeChildrenDisabledAndEscapeOutputDisabled: Inline syntax with argument in quotes, does encode variable value (encoded before passed to VH)' =>
82  [
83  '{ft:escapeChildrenDisabledAndEscapeOutputDisabled(content: \'{settings.test}\')}',
84  '&lt;strong&gt;Bla&lt;/strong&gt;'
85  ],
86  'EscapeChildrenDisabledAndEscapeOutputDisabled: Tag syntax with nested inline syntax and children rendering, does not encode variable value' =>
87  [
88  '<ft:escapeChildrenDisabledAndEscapeOutputDisabled content="{settings.test -> ft:escapeChildrenDisabledAndEscapeOutputDisabled()}" />',
89  '<strong>Bla</strong>'
90  ],
91  'EscapeChildrenDisabledAndEscapeOutputDisabled: Tag syntax with nested inline syntax and argument in inline, does not encode variable value' =>
92  [
93  '<ft:escapeChildrenDisabledAndEscapeOutputDisabled content="{ft:escapeChildrenDisabledAndEscapeOutputDisabled(content: settings.test)}" />',
94  '<strong>Bla</strong>'
95  ],
96 
97  ];
98  }
99 
107  public function renderingTest($viewHelperTemplate, $expectedOutput)
108  {
109  $view = new TemplateView();
110  $view->assign('settings', ['test' => '<strong>Bla</strong>']);
111  $view->getRenderingContext()->getViewHelperResolver()->addNamespace('ft', 'TYPO3Fluid\\FluidTest\\ViewHelpers');
112  $view->getRenderingContext()->getTemplatePaths()->setTemplateSource($viewHelperTemplate);
113 
114  $this->assertSame($expectedOutput, $view->render());
115  }
116 }