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