2 namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers;
27 $this->viewHelper = $this->getMock(\TYPO3\CMS\
Fluid\ViewHelpers\CaseViewHelper::class, array(
'buildRenderChildrenClosure'));
28 $this->viewHelper->expects($this->any())->method(
'buildRenderChildrenClosure')->will($this->returnValue(
function () {
32 $this->viewHelper->initializeArguments();
41 $this->viewHelperVariableContainer->expects($this->atLeastOnce())->method(
'exists')->with(\TYPO3\CMS\
Fluid\ViewHelpers\SwitchViewHelper::class,
'stateStack')->will($this->returnValue(
false));
42 $this->viewHelper->render(
'foo');
50 $this->viewHelperVariableContainer->expects($this->atLeastOnce())->method(
'exists')->with(\TYPO3\CMS\
Fluid\ViewHelpers\SwitchViewHelper::class,
'stateStack')->will($this->returnValue(
true));
51 $this->viewHelperVariableContainer->expects($this->atLeastOnce())->method(
'get')->with(\TYPO3\CMS\
Fluid\ViewHelpers\SwitchViewHelper::class,
'stateStack')->will($this->returnValue(array(array(
53 'expression' =>
'someValue'
56 $renderedChildNodes =
'ChildNodes';
58 $this->assertSame($renderedChildNodes, $this->viewHelper->render(
'someValue'));
66 $this->viewHelperVariableContainer->expects($this->atLeastOnce())->method(
'exists')->with(\TYPO3\CMS\
Fluid\ViewHelpers\SwitchViewHelper::class,
'stateStack')->will($this->returnValue(
true));
67 $this->viewHelperVariableContainer->expects($this->atLeastOnce())->method(
'get')->with(\TYPO3\CMS\
Fluid\ViewHelpers\SwitchViewHelper::class,
'stateStack')->will($this->returnValue(array(array(
69 'expression' =>
'someValue'
72 $this->viewHelperVariableContainer->expects($this->once())->method(
'addOrUpdate')->with(\TYPO3\CMS\
Fluid\ViewHelpers\SwitchViewHelper::class,
'stateStack', array(array(
74 'expression' =>
'someValue'
77 $this->viewHelper->render(
'someValue');
88 $this->viewHelperVariableContainer->expects($this->atLeastOnce())->method(
'exists')->with(\TYPO3\CMS\
Fluid\ViewHelpers\SwitchViewHelper::class,
'stateStack')->will($this->returnValue(
true));
89 $this->viewHelperVariableContainer->expects($this->atLeastOnce())->method(
'get')->with(\TYPO3\CMS\
Fluid\ViewHelpers\SwitchViewHelper::class,
'stateStack')->will($this->returnValue(array(array(
91 'expression' => $numericValue
94 $this->viewHelperVariableContainer->expects($this->once())->method(
'addOrUpdate')->with(\TYPO3\CMS\
Fluid\ViewHelpers\SwitchViewHelper::class,
'stateStack', array(array(
96 'expression' => $numericValue
99 $this->viewHelper->render($stringValue);
108 $this->viewHelperVariableContainer->expects($this->atLeastOnce())->method(
'exists')->with(\TYPO3\CMS\
Fluid\ViewHelpers\SwitchViewHelper::class,
'stateStack')->will($this->returnValue(
true));
109 $this->viewHelperVariableContainer->expects($this->atLeastOnce())->method(
'get')->with(\TYPO3\CMS\
Fluid\ViewHelpers\SwitchViewHelper::class,
'stateStack')->will($this->returnValue(array(array(
111 'expression' =>
'someValue'
114 $this->assertSame(
'', $this->viewHelper->render(
'someOtherValue'));
122 $this->viewHelperVariableContainer->expects(
123 $this->atLeastOnce())
125 ->with(\TYPO3\CMS\
Fluid\ViewHelpers\SwitchViewHelper::class,
'stateStack')
126 ->will($this->returnValue(
true)
128 $this->viewHelperVariableContainer->expects(
129 $this->atLeastOnce())->method(
'get')
130 ->with(\TYPO3\CMS\
Fluid\ViewHelpers\SwitchViewHelper::class,
'stateStack')
131 ->will($this->returnValue(array(array(
133 'expression' =>
'someExpression'
137 $renderedChildNodes =
'ChildNodes';
138 $this->viewHelper->expects($this->once())->method(
'buildRenderChildrenClosure')->will($this->returnValue(
function () {
142 $this->assertSame($renderedChildNodes, $this->viewHelper->render(null,
true));
151 $this->viewHelperVariableContainer->expects(
152 $this->atLeastOnce())
154 ->with(\TYPO3\CMS\
Fluid\ViewHelpers\SwitchViewHelper::class,
'stateStack')
155 ->will($this->returnValue(
true)
157 $this->viewHelperVariableContainer->expects($this->never())->method(
'get');
159 $this->viewHelper->render(null,
false);
167 $this->viewHelperVariableContainer->expects(
168 $this->atLeastOnce())
170 ->with(\TYPO3\CMS\
Fluid\ViewHelpers\SwitchViewHelper::class,
'stateStack')
171 ->will($this->returnValue(
true)
173 $this->viewHelperVariableContainer->expects(
174 $this->atLeastOnce())->method(
'get')
175 ->with(\TYPO3\CMS\
Fluid\ViewHelpers\SwitchViewHelper::class,
'stateStack')
176 ->will($this->returnValue(array(array(
178 'expression' =>
'someValue'
182 $renderedChildNodes =
'ChildNodes';
184 $this->assertSame($renderedChildNodes, $this->viewHelper->render(
'someOtherValue',
true));