TYPO3 CMS  TYPO3_6-2
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 
18 
23  $viewHelper = $this->getMock('TYPO3\\CMS\\Fluid\\ViewHelpers\\Format\\PaddingViewHelper', array('renderChildren'));
24  $viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('foo'));
25  $actualResult = $viewHelper->render(10);
26  $this->assertEquals('foo ', $actualResult);
27  }
28 
32  public function paddingStringCanBeSpecified() {
33  $viewHelper = $this->getMock('TYPO3\\CMS\\Fluid\\ViewHelpers\\Format\\PaddingViewHelper', array('renderChildren'));
34  $viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('foo'));
35  $actualResult = $viewHelper->render(10, '-=');
36  $this->assertEquals('foo-=-=-=-', $actualResult);
37  }
38 
43  $viewHelper = $this->getMock('TYPO3\\CMS\\Fluid\\ViewHelpers\\Format\\PaddingViewHelper', array('renderChildren'));
44  $viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('some long string'));
45  $actualResult = $viewHelper->render(5);
46  $this->assertEquals('some long string', $actualResult);
47  }
48 
52  public function integersArePaddedCorrectly() {
53  $viewHelper = $this->getMock('TYPO3\\CMS\\Fluid\\ViewHelpers\\Format\\PaddingViewHelper', array('renderChildren'));
54  $viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue(123));
55  $actualResult = $viewHelper->render(5, '0');
56  $this->assertEquals('12300', $actualResult);
57  }
58 }