TYPO3 CMS  TYPO3_6-2
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  public function setUp() {
27  $this->parsingState = new \TYPO3\CMS\Fluid\Core\Parser\ParsingState();
28  }
29 
33  public function setRootNodeCanBeReadOutAgain() {
34  $rootNode = new \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\RootNode();
35  $this->parsingState->setRootNode($rootNode);
36  $this->assertSame($this->parsingState->getRootNode(), $rootNode, 'Root node could not be read out again.');
37  }
38 
42  public function pushAndGetFromStackWorks() {
43  $rootNode = new \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\RootNode();
44  $this->parsingState->pushNodeToStack($rootNode);
45  $this->assertSame($rootNode, $this->parsingState->getNodeFromStack($rootNode), 'Node returned from stack was not the right one.');
46  $this->assertSame($rootNode, $this->parsingState->popNodeFromStack($rootNode), 'Node popped from stack was not the right one.');
47  }
48 
53  $renderingContext = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContextInterface');
54 
55  $rootNode = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\RootNode');
56  $rootNode->expects($this->once())->method('evaluate')->with($renderingContext)->will($this->returnValue('T3DD09 Rock!'));
57  $this->parsingState->setRootNode($rootNode);
58  $renderedValue = $this->parsingState->render($renderingContext);
59  $this->assertEquals($renderedValue, 'T3DD09 Rock!', 'The rendered value of the Root Node is not returned by the ParsingState.');
60  }
61 }