Exemplo n.º 1
0
 /**
  * @return ParsingState
  */
 protected function getParsingState()
 {
     $rootNode = new RootNode();
     $variableProvider = $this->renderingContext->getVariableProvider();
     $state = new ParsingState();
     $state->setRootNode($rootNode);
     $state->pushNodeToStack($rootNode);
     $state->setVariableProvider($variableProvider->getScopeCopy($variableProvider->getAll()));
     return $state;
 }
Exemplo n.º 2
0
 /**
  * @test
  */
 public function testGenerateSectionCodeFromParsingState()
 {
     $foo = new TextNode('foo');
     $bar = new TextNode('bar');
     $parsingState = new ParsingState();
     $container = new StandardVariableProvider(array('1457379500_sections' => array($foo, $bar)));
     $parsingState->setVariableProvider($container);
     $nodeConverter = $this->getMock(NodeConverter::class, array('convertListOfSubNodes'), array(), '', FALSE);
     $nodeConverter->expects($this->at(0))->method('convertListOfSubNodes')->with($foo)->willReturn(array());
     $nodeConverter->expects($this->at(1))->method('convertListOfSubNodes')->with($bar)->willReturn(array());
     $instance = $this->getMock(TemplateCompiler::class, array('generateCodeForSection'));
     $instance->expects($this->at(0))->method('generateCodeForSection')->with($this->anything())->willReturn('FOO');
     $instance->expects($this->at(1))->method('generateCodeForSection')->with($this->anything())->willReturn('BAR');
     $instance->setNodeConverter($nodeConverter);
     $method = new \ReflectionMethod($instance, 'generateSectionCodeFromParsingState');
     $method->setAccessible(TRUE);
     $result = $method->invokeArgs($instance, array($parsingState));
     $this->assertEquals('FOOBAR', $result);
 }
Exemplo n.º 3
0
 /**
  * @test
  */
 public function testGetLayoutName()
 {
     $this->parsingState->setVariableProvider(new StandardVariableProvider(array('layoutName' => 'test')));
     $result = $this->parsingState->getLayoutName(new RenderingContextFixture());
     $this->assertEquals('test', $result);
 }
Exemplo n.º 4
0
 /**
  * @return ParsingState
  */
 protected function getParsingState()
 {
     $rootNode = new RootNode();
     $state = new ParsingState();
     $state->setVariableProvider($this->variableProvider);
     $state->setViewHelperResolver($this->viewHelperResolver);
     $state->setRootNode($rootNode);
     $state->pushNodeToStack($rootNode);
     return $state;
 }