/** * @test */ public function elseArgumentHasPriorityOverChildNodesIfConditionIsFalse() { $mockElseViewHelperNode = $this->getMock('TYPO3Fluid\\Fluid\\Core\\Parser\\SyntaxTree\\ViewHelperNode', array('getViewHelperClassName', 'evaluate', 'setRenderingContext'), array(), '', FALSE); $mockElseViewHelperNode->expects($this->any())->method('getViewHelperClassName')->will($this->returnValue('TYPO3Fluid\\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); }
/** * @test */ public function elseArgumentHasPriorityOverChildNodesIfConditionIsFalse() { $mockElseViewHelperNode = $this->getMock(ViewHelperNode::class, ['getViewHelperClassName', 'evaluate', 'setRenderingContext'], [], '', false); $mockElseViewHelperNode->expects($this->any())->method('getViewHelperClassName')->will($this->returnValue(ElseViewHelper::class)); $mockElseViewHelperNode->expects($this->never())->method('evaluate'); $this->viewHelper->setChildNodes([$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); }