TYPO3 CMS  TYPO3_7-6
PrintfViewHelperTest.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(PrintfViewHelper::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('%04d-%02d-%02d'));
41  $actualResult = $this->viewHelper->render(['year' => 2009, 'month' => 4, 'day' => 5]);
42  $this->assertEquals('2009-04-05', $actualResult);
43  }
44 
49  {
50  $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('%2$s %1$d %3$s %2$s'));
51  $actualResult = $this->viewHelper->render([123, 'foo', 'bar']);
52  $this->assertEquals('foo 123 bar foo', $actualResult);
53  }
54 }
injectDependenciesIntoViewHelper(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper)