[TASK] Make Condition ViewHelpers fully static compileable
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Tests / Unit / ViewHelpers / IfViewHelperTest.php
1 <?php
2 namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers;
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 Lesser General Public License, either version 3 *
9 * of the License, or (at your option) any later version. *
10 * *
11 * The TYPO3 project - inspiring people to share! *
12 * */
13
14 /**
15 * Testcase for IfViewHelper
16 */
17 class IfViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\ViewHelperBaseTestcase {
18
19 /**
20 * @var \TYPO3\CMS\Fluid\ViewHelpers\IfViewHelper
21 */
22 protected $viewHelper;
23
24 /**
25 * @var \TYPO3\CMS\Fluid\Core\ViewHelper\Arguments
26 */
27 protected $mockArguments;
28
29 protected function setUp() {
30 parent::setUp();
31 $this->viewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\IfViewHelper::class, array('renderThenChild', 'renderElseChild'));
32 $this->injectDependenciesIntoViewHelper($this->viewHelper);
33 $this->viewHelper->initializeArguments();
34 }
35
36 /**
37 * @test
38 */
39 public function viewHelperRendersThenChildIfConditionIsTrue() {
40 $this->arguments['condition'] = TRUE;
41 $this->injectDependenciesIntoViewHelper($this->viewHelper);
42
43 $this->viewHelper->expects($this->at(0))->method('renderThenChild')->will($this->returnValue('foo'));
44
45 $actualResult = $this->viewHelper->render(TRUE);
46 $this->assertEquals('foo', $actualResult);
47 }
48
49 /**
50 * @test
51 */
52 public function viewHelperRendersElseChildIfConditionIsFalse() {
53 $this->viewHelper->expects($this->at(0))->method('renderElseChild')->will($this->returnValue('foo'));
54
55 $actualResult = $this->viewHelper->render(FALSE);
56 $this->assertEquals('foo', $actualResult);
57 }
58
59 }