‪TYPO3CMS  9.5
PaddingViewHelperTest.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 ‪PaddingViewHelperTest extends ViewHelperBaseTestcase
24 {
28  protected ‪$viewHelper;
29 
30  protected function ‪setUp()
31  {
32  parent::setUp();
33  $this->viewHelper = new ‪PaddingViewHelper();
34  $this->injectDependenciesIntoViewHelper($this->viewHelper);
35  }
36 
41  {
42  $this->viewHelper->setRenderChildrenClosure(
43  function () {
44  return 'foo';
45  }
46  );
47  $this->setArgumentsUnderTest(
48  $this->viewHelper,
49  [
50  'padLength' => 10
51  ]
52  );
53  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
54  $this->assertEquals('foo ', $actualResult);
55  }
56 
60  public function ‪paddingStringCanBeSpecified()
61  {
62  $this->viewHelper->setRenderChildrenClosure(
63  function () {
64  return 'foo';
65  }
66  );
67  $this->setArgumentsUnderTest(
68  $this->viewHelper,
69  [
70  'padLength' => 10,
71  'padString' => '-='
72  ]
73  );
74  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
75  $this->assertEquals('foo-=-=-=-', $actualResult);
76  }
77 
82  {
83  $this->viewHelper->setRenderChildrenClosure(
84  function () {
85  return 'some long string';
86  }
87  );
88  $this->setArgumentsUnderTest(
89  $this->viewHelper,
90  [
91  'padLength' => 5
92  ]
93  );
94  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
95  $this->assertEquals('some long string', $actualResult);
96  }
97 
101  public function ‪integersAreRespectedAsValue()
102  {
103  $this->viewHelper->setRenderChildrenClosure(
104  function () {
105  return 123;
106  }
107  );
108  $this->setArgumentsUnderTest(
109  $this->viewHelper,
110  [
111  'padLength' => 5,
112  'padString' => '0'
113  ]
114  );
115  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
116  $this->assertEquals('12300', $actualResult);
117  }
118 
122  public function ‪valueParameterIsRespected()
123  {
124  $this->setArgumentsUnderTest(
125  $this->viewHelper,
126  [
127  'value' => 'foo',
128  'padLength' => 5,
129  'padString' => '0',
130  ]
131  );
132  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
133  $this->assertEquals('foo00', $actualResult);
134  }
135 }
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\PaddingViewHelperTest\setUp
‪setUp()
Definition: PaddingViewHelperTest.php:29
‪TYPO3\CMS\Fluid\ViewHelpers\Format\PaddingViewHelper
Definition: PaddingViewHelper.php:60
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\PaddingViewHelperTest\valueParameterIsRespected
‪valueParameterIsRespected()
Definition: PaddingViewHelperTest.php:121
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\PaddingViewHelperTest
Definition: PaddingViewHelperTest.php:24
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format
Definition: BytesViewHelperTest.php:2
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\PaddingViewHelperTest\$viewHelper
‪PaddingViewHelper $viewHelper
Definition: PaddingViewHelperTest.php:27
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\PaddingViewHelperTest\stringIsNotTruncatedIfPadLengthIsBelowStringLength
‪stringIsNotTruncatedIfPadLengthIsBelowStringLength()
Definition: PaddingViewHelperTest.php:80
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\PaddingViewHelperTest\integersAreRespectedAsValue
‪integersAreRespectedAsValue()
Definition: PaddingViewHelperTest.php:100
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\PaddingViewHelperTest\stringsArePaddedWithBlanksByDefault
‪stringsArePaddedWithBlanksByDefault()
Definition: PaddingViewHelperTest.php:39
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\PaddingViewHelperTest\paddingStringCanBeSpecified
‪paddingStringCanBeSpecified()
Definition: PaddingViewHelperTest.php:59