TYPO3 CMS  TYPO3_7-6
ParsingStateTest.php
Go to the documentation of this file.
1 <?php
3 
4 /* *
5  * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6  * *
7  * It is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU Lesser General Public License, either version 3 *
9  * of the License, or (at your option) any later version. *
10  * *
11  * The TYPO3 project - inspiring people to share! *
12  * */
13 
18 {
24  protected $parsingState;
25 
26  protected function setUp()
27  {
28  $this->parsingState = new \TYPO3\CMS\Fluid\Core\Parser\ParsingState();
29  }
30 
34  public function setRootNodeCanBeReadOutAgain()
35  {
36  $rootNode = new \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\RootNode();
37  $this->parsingState->setRootNode($rootNode);
38  $this->assertSame($this->parsingState->getRootNode(), $rootNode, 'Root node could not be read out again.');
39  }
40 
44  public function pushAndGetFromStackWorks()
45  {
46  $rootNode = new \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\RootNode();
47  $this->parsingState->pushNodeToStack($rootNode);
48  $this->assertSame($rootNode, $this->parsingState->getNodeFromStack($rootNode), 'Node returned from stack was not the right one.');
49  $this->assertSame($rootNode, $this->parsingState->popNodeFromStack($rootNode), 'Node popped from stack was not the right one.');
50  }
51 
56  {
57  $renderingContext = $this->getMock(\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface::class);
58 
59  $rootNode = $this->getMock(\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\RootNode::class);
60  $rootNode->expects($this->once())->method('evaluate')->with($renderingContext)->will($this->returnValue('T3DD09 Rock!'));
61  $this->parsingState->setRootNode($rootNode);
62  $renderedValue = $this->parsingState->render($renderingContext);
63  $this->assertEquals($renderedValue, 'T3DD09 Rock!', 'The rendered value of the Root Node is not returned by the ParsingState.');
64  }
65 }