‪TYPO3CMS  ‪main
CshViewHelperTest.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 
23 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
24 use TYPO3Fluid\Fluid\View\TemplateView;
25 
26 final class ‪CshViewHelperTest extends FunctionalTestCase
27 {
28  protected bool ‪$initializeDatabase = false;
29 
30  protected function ‪setUp(): void
31  {
32  parent::setUp();
33  if (!isset(‪$GLOBALS['LANG'])) {
34  ‪$GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default');
35  }
36  }
37 
38  public static function ‪isRenderedDataProvider(): array
39  {
40  return [
41  '#1' => [
42  '<f:be.labels.csh table="table" field="field" label="{label}">{variable}</f:be.labels.csh>',
43  [
44  'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.goBack',
45  'variable' => 'variable<>&"\'',
46  ],
47  '<label>Go back</label>',
48  ],
49  '#2' => [
50  '<f:be.labels.csh table="table" field="field" label="{label}">{variable}</f:be.labels.csh>',
51  [
52  'label' => 'label<>&"\'',
53  'variable' => 'variable<>&"\'',
54  ],
55  '<label>label&lt;&gt;&amp;&quot;&#039;</label>',
56  ],
57  '#3' => [
58  '{f:be.labels.csh(table:\'table\', field:\'field\', label:label)}',
59  [
60  'label' => 'label<>&"\'',
61  'variable' => 'variable<>&"\'',
62  ],
63  '<label>label&lt;&gt;&amp;&quot;&#039;</label>',
64  ],
65  '#4' => [
66  '{f:be.labels.csh(table:\'table\', field:\'field\', label:\'{label}\')}',
67  [
68  'label' => 'label<>&"\'',
69  'variable' => 'variable<>&"\'',
70  ],
71  '<label>label&lt;&gt;&amp;&quot;&#039;</label>',
72  ],
73  ];
74  }
75 
80  public function ‪isRendered(string $source, array $variables, string $expectation): void
81  {
82  $context = $this->get(RenderingContextFactory::class)->create();
83  $context->getTemplatePaths()->setTemplateSource($source);
84  $view = new TemplateView($context);
85  $view->getRenderingContext()->getCache()->flush();
86  $view->assignMultiple($variables);
87  self::assertSame($expectation, $view->render());
88  }
89 }
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory
Definition: LanguageServiceFactory.php:25
‪TYPO3\CMS\Fluid\Tests\FunctionalDeprecated\ViewHelpers\Be\Labels\CshViewHelperTest
Definition: CshViewHelperTest.php:27
‪TYPO3\CMS\Fluid\Tests\FunctionalDeprecated\ViewHelpers\Be\Labels\CshViewHelperTest\$initializeDatabase
‪bool $initializeDatabase
Definition: CshViewHelperTest.php:28
‪TYPO3\CMS\Fluid\Tests\FunctionalDeprecated\ViewHelpers\Be\Labels
Definition: CshViewHelperTest.php:18
‪TYPO3\CMS\Fluid\Tests\FunctionalDeprecated\ViewHelpers\Be\Labels\CshViewHelperTest\setUp
‪setUp()
Definition: CshViewHelperTest.php:30
‪TYPO3\CMS\Fluid\Tests\FunctionalDeprecated\ViewHelpers\Be\Labels\CshViewHelperTest\isRenderedDataProvider
‪static isRenderedDataProvider()
Definition: CshViewHelperTest.php:38
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory
Definition: RenderingContextFactory.php:51
‪TYPO3\CMS\Fluid\Tests\FunctionalDeprecated\ViewHelpers\Be\Labels\CshViewHelperTest\isRendered
‪isRendered(string $source, array $variables, string $expectation)
Definition: CshViewHelperTest.php:80
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:51