‪TYPO3CMS  10.4
PaddingViewHelperTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
20 
24 class ‪PaddingViewHelperTest extends ViewHelperBaseTestcase
25 {
29  protected ‪$viewHelper;
30 
31  protected function ‪setUp(): void
32  {
33  parent::setUp();
34  $this->viewHelper = new ‪PaddingViewHelper();
35  $this->injectDependenciesIntoViewHelper($this->viewHelper);
36  }
37 
42  {
43  $this->viewHelper->setRenderChildrenClosure(
44  function () {
45  return 'foo';
46  }
47  );
48  $this->setArgumentsUnderTest(
49  $this->viewHelper,
50  [
51  'padLength' => 10
52  ]
53  );
54  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
55  self::assertEquals('foo ', $actualResult);
56  }
57 
61  public function ‪paddingStringCanBeSpecified()
62  {
63  $this->viewHelper->setRenderChildrenClosure(
64  function () {
65  return 'foo';
66  }
67  );
68  $this->setArgumentsUnderTest(
69  $this->viewHelper,
70  [
71  'padLength' => 10,
72  'padString' => '-='
73  ]
74  );
75  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
76  self::assertEquals('foo-=-=-=-', $actualResult);
77  }
78 
83  {
84  $this->viewHelper->setRenderChildrenClosure(
85  function () {
86  return 'some long string';
87  }
88  );
89  $this->setArgumentsUnderTest(
90  $this->viewHelper,
91  [
92  'padLength' => 5
93  ]
94  );
95  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
96  self::assertEquals('some long string', $actualResult);
97  }
98 
102  public function ‪integersAreRespectedAsValue()
103  {
104  $this->viewHelper->setRenderChildrenClosure(
105  function () {
106  return 123;
107  }
108  );
109  $this->setArgumentsUnderTest(
110  $this->viewHelper,
111  [
112  'padLength' => 5,
113  'padString' => '0'
114  ]
115  );
116  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
117  self::assertEquals('12300', $actualResult);
118  }
119 
123  public function ‪valueParameterIsRespected()
124  {
125  $this->setArgumentsUnderTest(
126  $this->viewHelper,
127  [
128  'value' => 'foo',
129  'padLength' => 5,
130  'padString' => '0',
131  ]
132  );
133  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
134  self::assertEquals('foo00', $actualResult);
135  }
136 }
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\PaddingViewHelperTest\setUp
‪setUp()
Definition: PaddingViewHelperTest.php:30
‪TYPO3\CMS\Fluid\ViewHelpers\Format\PaddingViewHelper
Definition: PaddingViewHelper.php:62
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\PaddingViewHelperTest\valueParameterIsRespected
‪valueParameterIsRespected()
Definition: PaddingViewHelperTest.php:122
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\PaddingViewHelperTest
Definition: PaddingViewHelperTest.php:25
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format
Definition: ScriptViewHelperTest.php:18
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\PaddingViewHelperTest\$viewHelper
‪PaddingViewHelper $viewHelper
Definition: PaddingViewHelperTest.php:28
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\PaddingViewHelperTest\stringIsNotTruncatedIfPadLengthIsBelowStringLength
‪stringIsNotTruncatedIfPadLengthIsBelowStringLength()
Definition: PaddingViewHelperTest.php:81
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\PaddingViewHelperTest\integersAreRespectedAsValue
‪integersAreRespectedAsValue()
Definition: PaddingViewHelperTest.php:101
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\PaddingViewHelperTest\stringsArePaddedWithBlanksByDefault
‪stringsArePaddedWithBlanksByDefault()
Definition: PaddingViewHelperTest.php:40
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\PaddingViewHelperTest\paddingStringCanBeSpecified
‪paddingStringCanBeSpecified()
Definition: PaddingViewHelperTest.php:60