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