/**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testParseExpressionNameWithVariables()
 {
     $expectedLine = 101;
     $variablesExpr = $this->createExpressionNode();
     $token = $this->createToken();
     $token->expects($this->any())->method('getLine')->will($this->returnValue($expectedLine));
     $nameToken = $this->createToken();
     $nameTokenValue = 'nameTokenValue';
     $nameTokenLine = 102;
     $nameToken->expects($this->once())->method('getValue')->will($this->returnValue($nameTokenValue));
     $nameToken->expects($this->once())->method('getLine')->will($this->returnValue($nameTokenLine));
     $this->stream->expects($this->at(0))->method('test')->with(\Twig_Token::NAME_TYPE)->will($this->returnValue(true));
     $this->stream->expects($this->at(1))->method('getCurrent')->will($this->returnValue($nameToken));
     $this->stream->expects($this->at(2))->method('next');
     $this->stream->expects($this->at(3))->method('nextIf')->with(\Twig_Token::NAME_TYPE, 'with')->will($this->returnValue(true));
     $this->expressionParser->expects($this->once())->method('parseExpression')->will($this->returnValue($variablesExpr));
     $this->stream->expects($this->at(4))->method('expect')->with(\Twig_Token::BLOCK_END_TYPE);
     $actualNode = $this->tokenParser->parse($token);
     $this->assertInstanceOf('\\Twig_Node_Print', $actualNode);
     $this->assertEquals($expectedLine, $actualNode->getLine());
     $this->assertEquals('placeholder', $actualNode->getNodeTag());
     $expectedNameExpr = new \Twig_Node_Expression_Filter_Default(new \Twig_Node_Expression_Name($nameTokenValue, $nameTokenLine), new \Twig_Node_Expression_Constant('default', $nameTokenLine), new \Twig_Node(array(new \Twig_Node_Expression_Constant($nameTokenValue, $nameTokenLine)), array(), $nameTokenLine), $nameTokenLine);
     $expectedExpr = new \Twig_Node_Expression_Function('placeholder', new \Twig_Node(array('name' => $expectedNameExpr, 'variables' => $variablesExpr)), $expectedLine);
     $this->compiler->expects($this->once())->method('addDebugInfo')->with($this->identicalTo($actualNode))->will($this->returnSelf());
     $this->compiler->expects($this->once())->method('write')->with('echo ')->will($this->returnSelf());
     $this->compiler->expects($this->once())->method('subcompile')->with($expectedExpr)->will($this->returnSelf());
     $this->compiler->expects($this->once())->method('raw')->with(";\n")->will($this->returnSelf());
     $actualNode->compile($this->compiler);
 }
 public function testParse()
 {
     $startToken = new \Twig_Token(\Twig_Token::NAME_TYPE, 'placeholder', 12);
     $stream = new \Twig_TokenStream([new \Twig_Token(\Twig_Token::NAME_TYPE, 'test_position', 12), new \Twig_Token(\Twig_Token::NAME_TYPE, 'with', 12), new \Twig_Token(\Twig_Token::BLOCK_END_TYPE, '', 12), new \Twig_Token(\Twig_Token::EOF_TYPE, '', 12)]);
     $expressionParser = $this->getMockBuilder('\\Twig_ExpressionParser')->disableOriginalConstructor()->getMock();
     $parser = $this->getMockBuilder('\\Twig_Parser')->disableOriginalConstructor()->getMock();
     $parser->expects($this->once())->method('getStream')->will($this->returnValue($stream));
     $parser->expects($this->once())->method('getExpressionParser')->will($this->returnValue($expressionParser));
     $expressionParser->expects($this->once())->method('parseExpression')->will($this->returnValue(null));
     $this->placeholder->setParser($parser);
     $resultNode = $this->placeholder->parse($startToken);
     $this->assertEquals(12, $resultNode->getLine());
     $this->assertEquals('placeholder', $resultNode->getNodeTag());
 }