‪TYPO3CMS  11.5
CaseViewHelperTest.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 
21 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
22 use TYPO3Fluid\Fluid\Core\ViewHelper\Exception;
23 
24 class ‪CaseViewHelperTest extends FunctionalTestCase
25 {
29  protected ‪$initializeDatabase = false;
30 
31  public function ‪renderConvertsAValueDataProvider(): array
32  {
33  return [
34  'empty value' => [
35  '<f:format.case value="" />',
36  '',
37  ],
38  'value from child, uppercase default' => [
39  '<f:format.case>foob4r</f:format.case>',
40  'FOOB4R',
41  ],
42  'simple value' => [
43  '<f:format.case value="foo" />',
44  'FOO',
45  ],
46  'mode lower' => [
47  '<f:format.case value="FooB4r" mode="lower" />',
48  'foob4r',
49  ],
50  'mode upper' => [
51  '<f:format.case value="FooB4r" mode="upper" />',
52  'FOOB4R',
53  ],
54  'mode capital' => [
55  '<f:format.case value="foo bar" mode="capital" />',
56  'Foo bar',
57  ],
58  'mode uncapital' => [
59  '<f:format.case value="FOO Bar" mode="uncapital" />',
60  'fOO Bar',
61  ],
62  'mode capital words' => [
63  '<f:format.case value="foo bar baz" mode="capitalWords" />',
64  'Foo Bar Baz',
65  ],
66  'special chars 1' => [
67  '<f:format.case value="smørrebrød" mode="upper" />',
68  'SMØRREBRØD',
69  ],
70  'special chars 2' => [
71  '<f:format.case value="smørrebrød" mode="capital" />',
72  'Smørrebrød',
73  ],
74  'special chars 3' => [
75  '<f:format.case value="römtömtömtöm" mode="upper" />',
76  'RÖMTÖMTÖMTÖM',
77  ],
78  'special chars 4' => [
79  '<f:format.case value="Ἕλλάς α ω" mode="upper" />',
80  'ἝΛΛΆΣ Α Ω',
81  ],
82  ];
83  }
84 
89  public function ‪renderConvertsAValue(string $src, string $expected): void
90  {
91  $view = new ‪StandaloneView();
92  $view->setTemplateSource($src);
93  self::assertSame($expected, $view->render());
94  }
95 
100  {
101  $this->expectException(Exception::class);
102  $this->expectExceptionCode(1358349150);
103  $view = new ‪StandaloneView();
104  $view->setTemplateSource('<f:format.case value="foo" mode="invalid" />');
105  $view->render();
106  }
107 }
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format
Definition: BytesViewHelperTest.php:18
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:31
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format\CaseViewHelperTest\renderConvertsAValue
‪renderConvertsAValue(string $src, string $expected)
Definition: CaseViewHelperTest.php:88
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format\CaseViewHelperTest\renderConvertsAValueDataProvider
‪renderConvertsAValueDataProvider()
Definition: CaseViewHelperTest.php:30
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format\CaseViewHelperTest
Definition: CaseViewHelperTest.php:25
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format\CaseViewHelperTest\$initializeDatabase
‪bool $initializeDatabase
Definition: CaseViewHelperTest.php:28
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Format\CaseViewHelperTest\viewHelperThrowsExceptionIfIncorrectModeIsGiven
‪viewHelperThrowsExceptionIfIncorrectModeIsGiven()
Definition: CaseViewHelperTest.php:98