/**
  * @test
  */
 public function pushAndGetFromStackWorks()
 {
     $rootNode = new \TYPO3\Fluid\Core\Parser\SyntaxTree\RootNode();
     $this->parsingState->pushNodeToStack($rootNode);
     $this->assertSame($rootNode, $this->parsingState->getNodeFromStack($rootNode), 'Node returned from stack was not the right one.');
     $this->assertSame($rootNode, $this->parsingState->popNodeFromStack($rootNode), 'Node popped from stack was not the right one.');
 }
 /**
  * Handles a closing view helper tag
  *
  * @param ParsingState $state The current parsing state
  * @param string $namespaceIdentifier Namespace identifier for the closing tag.
  * @param string $methodIdentifier Method identifier.
  * @return boolean whether the viewHelper was found and added to the stack or not
  * @throws Exception
  */
 protected function closingViewHelperTagHandler(ParsingState $state, $namespaceIdentifier, $methodIdentifier)
 {
     if ($this->isNamespaceValid($namespaceIdentifier, $methodIdentifier) === FALSE) {
         return FALSE;
     }
     $lastStackElement = $state->popNodeFromStack();
     if (!$lastStackElement instanceof ViewHelperNode) {
         throw new Exception('You closed a templating tag which you never opened!', 1224485838);
     }
     if ($lastStackElement->getViewHelperClassName() != $this->resolveViewHelperName($namespaceIdentifier, $methodIdentifier)) {
         throw new Exception('Templating tags not properly nested. Expected: ' . $lastStackElement->getViewHelperClassName() . '; Actual: ' . $this->resolveViewHelperName($namespaceIdentifier, $methodIdentifier), 1224485398);
     }
     $this->callInterceptor($lastStackElement, InterceptorInterface::INTERCEPT_CLOSING_VIEWHELPER, $state);
     $state->getNodeFromStack()->addChildNode($lastStackElement);
     return TRUE;
 }
 /**
  * Handles a closing view helper tag
  *
  * @param ParsingState $state The current parsing state
  * @param string $namespaceIdentifier Namespace identifier for the closing tag.
  * @param string $methodIdentifier Method identifier.
  * @return void
  * @throws Exception
  */
 protected function closingViewHelperTagHandler(ParsingState $state, $namespaceIdentifier, $methodIdentifier)
 {
     if (!array_key_exists($namespaceIdentifier, $this->namespaces)) {
         throw new Exception('Namespace could not be resolved. This exception should never be thrown!', 1224256186);
     }
     $lastStackElement = $state->popNodeFromStack();
     if (!$lastStackElement instanceof ViewHelperNode) {
         throw new Exception('You closed a templating tag which you never opened!', 1224485838);
     }
     if ($lastStackElement->getViewHelperClassName() != $this->resolveViewHelperName($namespaceIdentifier, $methodIdentifier)) {
         throw new Exception('Templating tags not properly nested. Expected: ' . $lastStackElement->getViewHelperClassName() . '; Actual: ' . $this->resolveViewHelperName($namespaceIdentifier, $methodIdentifier), 1224485398);
     }
     $this->callInterceptor($lastStackElement, InterceptorInterface::INTERCEPT_CLOSING_VIEWHELPER, $state);
 }