/** * @return array */ public function getConvertTestValues() { $treeBooleanRoot = new RootNode(); $treeBooleanRoot->addChildNode(new TextNode('1')); $treeBooleanRoot->addChildNode(new TextNode('!=')); $treeBooleanRoot->addChildNode(new TextNode('2')); $treeBoolean = new BooleanNode($treeBooleanRoot); $simpleRoot = new RootNode(); $simpleRoot->addChildNode(new TextNode('foobar')); return array(array(new ObjectAccessorNode('_all'), '$renderingContext->getVariableProvider()->getAll()'), array(new BooleanNode(new TextNode('TRUE')), '\\NamelessCoder\\Fluid\\Core\\Parser\\SyntaxTree\\BooleanNode::evaluateStack($renderingContext, $array0)'), array(new BooleanNode(new TextNode('1 = 1')), '\\NamelessCoder\\Fluid\\Core\\Parser\\SyntaxTree\\BooleanNode::evaluateStack($renderingContext, $array0)'), array($treeBoolean, '\\NamelessCoder\\Fluid\\Core\\Parser\\SyntaxTree\\BooleanNode::evaluateStack($renderingContext, $array0)'), array(new TernaryExpressionNode('1 ? 2 : 3', array(1, 2, 3)), '\\NamelessCoder\\Fluid\\Core\\Parser\\SyntaxTree\\Expression\\TernaryExpressionNode::evaluateExpression($renderingContext, $string0, $array1)'), array($simpleRoot, '\'foobar\''), array(new TextNode('test'), '\'test\''), array(new NumericNode('3'), '3'), array(new NumericNode('4.5'), '4.5'), array(new ArrayNode(array('foo', 'bar')), '$array0'), array(new ArrayNode(array(0, new TextNode('test'), new ArrayNode(array('foo', 'bar')))), '$array0')); }
/** * @test */ public function objectsAreComparedStrictlyInUnequalComparison() { $object1 = new \stdClass(); $object2 = new \stdClass(); $rootNode = new RootNode(); $object1Node = $this->getMock('NamelessCoder\\Fluid\\Core\\Parser\\SyntaxTree\\ObjectAccessorNode', array('evaluate'), array('foo')); $object1Node->expects($this->any())->method('evaluate')->will($this->returnValue($object1)); $object2Node = $this->getMock('NamelessCoder\\Fluid\\Core\\Parser\\SyntaxTree\\ObjectAccessorNode', array('evaluate'), array('foo')); $object2Node->expects($this->any())->method('evaluate')->will($this->returnValue($object2)); $rootNode->addChildNode($object1Node); $rootNode->addChildNode(new TextNode('!=')); $rootNode->addChildNode($object2Node); $booleanNode = new BooleanNode($rootNode); $this->assertTrue($booleanNode->evaluate($this->renderingContext)); }
/** * Render the parsed template with rendering context * * @param RenderingContextInterface $renderingContext The rendering context to use * @return string Rendered string */ public function render(RenderingContextInterface $renderingContext) { return $this->rootNode->evaluate($renderingContext); }