‪TYPO3CMS  9.5
CaseViewHelperTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
19 
23 class ‪CaseViewHelperTest extends ViewHelperBaseTestcase
24 {
28  protected ‪$viewHelper;
29 
30  protected function ‪setUp()
31  {
32  parent::setUp();
33  $this->viewHelper = new ‪CaseViewHelper();
34  $this->injectDependenciesIntoViewHelper($this->viewHelper);
35  }
36 
41  {
42  $this->setArgumentsUnderTest(
43  $this->viewHelper,
44  [
45  'value' => ''
46  ]
47  );
48  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
49  $this->assertEquals('', $actualResult);
50  }
51 
56  {
57  $this->setArgumentsUnderTest(
58  $this->viewHelper,
59  [
60  'value' => 'Some string'
61  ]
62  );
63  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
64  $this->assertEquals('SOME STRING', $actualResult);
65  }
66 
71  {
72  $this->expectException(\‪TYPO3Fluid\Fluid\Core\Exception::class);
73  $this->expectExceptionCode(1358349150);
74  $this->setArgumentsUnderTest(
75  $this->viewHelper,
76  [
77  'value' => 'Foo',
78  'mode' => 'incorrectMode'
79  ]
80  );
81  $this->viewHelper->initializeArgumentsAndRender();
82  }
83 
88  {
89  $this->setArgumentsUnderTest(
90  $this->viewHelper,
91  [
92  'value' => 'FooB4r'
93  ]
94  );
95  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
96  $this->assertSame('FOOB4R', $actualResult);
97  }
98 
102  public function ‪conversionTestingDataProvider()
103  {
104  return [
105  ['FooB4r', ‪CaseViewHelper::CASE_LOWER, 'foob4r'],
106  ['FooB4r', ‪CaseViewHelper::CASE_UPPER, 'FOOB4R'],
107  ['foo bar', ‪CaseViewHelper::CASE_CAPITAL, 'Foo bar'],
108  ['FOO Bar', ‪CaseViewHelper::CASE_UNCAPITAL, 'fOO Bar'],
109  ['smørrebrød', ‪CaseViewHelper::CASE_UPPER, 'SMØRREBRØD'],
110  ['smørrebrød', ‪CaseViewHelper::CASE_CAPITAL, 'Smørrebrød'],
111  ['römtömtömtöm', ‪CaseViewHelper::CASE_UPPER, 'RÖMTÖMTÖMTÖM'],
112  ['Ἕλλάς α ω', ‪CaseViewHelper::CASE_UPPER, 'ἝΛΛΆΣ Α Ω'],
113  ];
114  }
115 
120  public function ‪viewHelperConvertsCorrectly($input, $mode, $expected)
121  {
122  $this->setArgumentsUnderTest(
123  $this->viewHelper,
124  [
125  'value' => $input,
126  'mode' => $mode
127  ]
128  );
129  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
130  $this->assertSame($expected, $actualResult, sprintf('The conversion with mode "%s" did not perform as expected.', $mode));
131  }
132 }
‪TYPO3Fluid
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\CaseViewHelperTest\conversionTestingDataProvider
‪conversionTestingDataProvider()
Definition: CaseViewHelperTest.php:101
‪TYPO3\CMS\Fluid\ViewHelpers\Format\CaseViewHelper\CASE_LOWER
‪const CASE_LOWER
Definition: CaseViewHelper.php:79
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\CaseViewHelperTest
Definition: CaseViewHelperTest.php:24
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\CaseViewHelperTest\viewHelperConvertsCorrectly
‪viewHelperConvertsCorrectly($input, $mode, $expected)
Definition: CaseViewHelperTest.php:119
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\CaseViewHelperTest\viewHelperThrowsExceptionIfIncorrectModeIsGiven
‪viewHelperThrowsExceptionIfIncorrectModeIsGiven()
Definition: CaseViewHelperTest.php:69
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format
Definition: BytesViewHelperTest.php:2
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\CaseViewHelperTest\viewHelperDoesNotRenderChildrenIfGivenValueIsNotNull
‪viewHelperDoesNotRenderChildrenIfGivenValueIsNotNull()
Definition: CaseViewHelperTest.php:54
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\CaseViewHelperTest\viewHelperRendersChildrenIfGivenValueIsNull
‪viewHelperRendersChildrenIfGivenValueIsNull()
Definition: CaseViewHelperTest.php:39
‪TYPO3\CMS\Fluid\ViewHelpers\Format\CaseViewHelper\CASE_UPPER
‪const CASE_UPPER
Definition: CaseViewHelper.php:84
‪TYPO3\CMS\Fluid\ViewHelpers\Format\CaseViewHelper\CASE_UNCAPITAL
‪const CASE_UNCAPITAL
Definition: CaseViewHelper.php:94
‪TYPO3\CMS\Fluid\ViewHelpers\Format\CaseViewHelper
Definition: CaseViewHelper.php:74
‪TYPO3\CMS\Fluid\ViewHelpers\Format\CaseViewHelper\CASE_CAPITAL
‪const CASE_CAPITAL
Definition: CaseViewHelper.php:89
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\CaseViewHelperTest\viewHelperConvertsUppercasePerDefault
‪viewHelperConvertsUppercasePerDefault()
Definition: CaseViewHelperTest.php:86
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\CaseViewHelperTest\setUp
‪setUp()
Definition: CaseViewHelperTest.php:29
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\CaseViewHelperTest\$viewHelper
‪CaseViewHelper $viewHelper
Definition: CaseViewHelperTest.php:27