[FEATURE] Switch View Helper
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Tests / Unit / ViewHelpers / SwitchViewHelperTest.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 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 require_once(__DIR__ . '/ViewHelperBaseTestcase.php');
15
16 /**
17 * Testcase for SwitchViewHelper
18 */
19 class SwitchViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\ViewHelperBaseTestcase {
20
21 /**
22 * @var \TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper
23 */
24 protected $viewHelper;
25
26 public function setUp() {
27 parent::setUp();
28 $this->viewHelper = $this->getMock('TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper', array('renderChildren'));
29 $this->injectDependenciesIntoViewHelper($this->viewHelper);
30 $this->viewHelper->initializeArguments();
31 }
32
33 /**
34 * @test
35 */
36 public function renderSetsSwitchExpressionInViewHelperVariableContainer() {
37 $switchExpression = new \stdClass();
38 $this->viewHelperVariableContainer->expects($this->at(2))->method('addOrUpdate')->with('TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper', 'switchExpression', $switchExpression);
39 $this->viewHelper->render($switchExpression);
40 }
41
42 /**
43 * @test
44 */
45 public function renderRemovesSwitchExpressionFromViewHelperVariableContainerAfterInvocation() {
46 $this->viewHelperVariableContainer->expects($this->at(4))->method('remove')->with('TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper', 'switchExpression');
47 $this->viewHelper->render('switchExpression');
48 }
49 }
50
51 ?>