[TASK] Use ::class where possible in fluid unit tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Tests / Unit / ViewHelpers / Format / PrintfViewHelperTest.php
1 <?php
2 namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format;
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
14 use TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\ViewHelperBaseTestcase;
15 use TYPO3\CMS\Fluid\ViewHelpers\Format\PrintfViewHelper;
16
17 /**
18 * Test case
19 */
20 class PrintfViewHelperTest extends ViewHelperBaseTestcase {
21
22 /**
23 * @var PrintfViewHelper
24 */
25 protected $viewHelper;
26
27 protected function setUp() {
28 parent::setUp();
29 $this->viewHelper = $this->getMock(PrintfViewHelper::class, array('renderChildren'));
30 $this->injectDependenciesIntoViewHelper($this->viewHelper);
31 $this->viewHelper->initializeArguments();
32 }
33
34 /**
35 * @test
36 */
37 public function viewHelperCanUseArrayAsArgument() {
38 $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('%04d-%02d-%02d'));
39 $actualResult = $this->viewHelper->render(array('year' => 2009, 'month' => 4, 'day' => 5));
40 $this->assertEquals('2009-04-05', $actualResult);
41 }
42
43 /**
44 * @test
45 */
46 public function viewHelperCanSwapMultipleArguments() {
47 $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('%2$s %1$d %3$s %2$s'));
48 $actualResult = $this->viewHelper->render(array(123, 'foo', 'bar'));
49 $this->assertEquals('foo 123 bar foo', $actualResult);
50 }
51
52 }