/** * @test */ public function renderThenChildReturnsEmptyStringIfChildNodesOnlyContainElseViewHelper() { $mockElseViewHelperNode = $this->getMock(\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode::class, array('getViewHelperClassName', 'evaluate'), array(), '', false); $mockElseViewHelperNode->expects($this->any())->method('getViewHelperClassName')->will($this->returnValue(\TYPO3\CMS\Fluid\ViewHelpers\ElseViewHelper::class)); $this->viewHelper->setChildNodes(array($mockElseViewHelperNode)); $this->viewHelper->expects($this->never())->method('renderChildren')->will($this->returnValue('Child nodes')); $actualResult = $this->viewHelper->_call('renderThenChild'); $this->assertEquals('', $actualResult); }
/** * @test */ public function elseArgumentHasPriorityOverChildNodesIfConditionIsFalse() { $mockElseViewHelperNode = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\ViewHelperNode', array('getViewHelperClassName', 'evaluate', 'setRenderingContext'), array(), '', FALSE); $mockElseViewHelperNode->expects($this->any())->method('getViewHelperClassName')->will($this->returnValue('TYPO3\\CMS\\Fluid\\ViewHelpers\\ElseViewHelper')); $mockElseViewHelperNode->expects($this->never())->method('evaluate'); $this->viewHelper->setChildNodes(array($mockElseViewHelperNode)); $this->viewHelper->expects($this->atLeastOnce())->method('hasArgument')->with('else')->will($this->returnValue(TRUE)); $this->arguments['else'] = 'ElseArgument'; $this->injectDependenciesIntoViewHelper($this->viewHelper); $actualResult = $this->viewHelper->_call('renderElseChild'); $this->assertEquals('ElseArgument', $actualResult); }