TYPO3 CMS  TYPO3_7-6
PaddingViewHelperTest.php
Go to the documentation of this file.
1 <?php
3 
4 /* *
5  * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
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 3 of the *
9  * License, or (at your option) any later version. *
10  * *
11  * The TYPO3 project - inspiring people to share! *
12  * */
13 
16 
21 {
25  protected $viewHelper;
26 
27  protected function setUp()
28  {
29  parent::setUp();
30  $this->viewHelper = $this->getMock(PaddingViewHelper::class, ['renderChildren']);
31  $this->injectDependenciesIntoViewHelper($this->viewHelper);
32  $this->viewHelper->initializeArguments();
33  }
34 
39  {
40  $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('foo'));
41  $actualResult = $this->viewHelper->render(10);
42  $this->assertEquals('foo ', $actualResult);
43  }
44 
48  public function paddingStringCanBeSpecified()
49  {
50  $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('foo'));
51  $actualResult = $this->viewHelper->render(10, '-=');
52  $this->assertEquals('foo-=-=-=-', $actualResult);
53  }
54 
59  {
60  $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('some long string'));
61  $actualResult = $this->viewHelper->render(5);
62  $this->assertEquals('some long string', $actualResult);
63  }
64 
68  public function integersArePaddedCorrectly()
69  {
70  $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue(123));
71  $actualResult = $this->viewHelper->render(5, '0');
72  $this->assertEquals('12300', $actualResult);
73  }
74 }
injectDependenciesIntoViewHelper(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper)