TYPO3 CMS  TYPO3_7-6
SwitchViewHelperTest.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 {
22  protected $viewHelper;
23 
24  protected function setUp()
25  {
26  parent::setUp();
27  $this->viewHelper = $this->getMock(\TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper::class, ['renderChildren']);
28  $this->injectDependenciesIntoViewHelper($this->viewHelper);
29  $this->viewHelper->initializeArguments();
30  }
31 
36  {
37  $switchExpression = new \stdClass();
38  $this->viewHelperVariableContainer->expects($this->at(1))->method('addOrUpdate')->with(\TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper::class, 'stateStack', [[
39  'break' => false,
40  'expression' => $switchExpression
41  ]]);
42  $this->viewHelperVariableContainer->expects($this->at(2))->method('get')->will($this->returnValue([[
43  'break' => true,
44  'expression' => $switchExpression
45  ]]));
46  $this->viewHelper->render($switchExpression);
47  }
48 
53  {
54  $this->viewHelperVariableContainer->expects($this->at(1))->method('addOrUpdate')->with(\TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper::class, 'stateStack', [[
55  'break' => false,
56  'expression' => 'switchExpression'
57  ]]);
58  $this->viewHelperVariableContainer->expects($this->at(2))->method('get')->will($this->returnValue([[
59  'break' => true,
60  'expression' => 'switchExpression'
61  ]]));
62  $this->viewHelperVariableContainer->expects($this->at(3))->method('addOrUpdate')->with(\TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper::class, 'stateStack', []);
63  $this->viewHelper->render('switchExpression');
64  }
65 }
injectDependenciesIntoViewHelper(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper)