/** * 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->viewHelperResolver->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); } $actualViewHelperClassName = $this->viewHelperResolver->resolveViewHelperClassName($namespaceIdentifier, $methodIdentifier); $expectedViewHelperClassName = $lastStackElement->getViewHelperClassName(); if ($actualViewHelperClassName !== $expectedViewHelperClassName) { throw new Exception('Templating tags not properly nested. Expected: ' . $expectedViewHelperClassName . '; Actual: ' . $actualViewHelperClassName, 1224485398); } $this->callInterceptor($lastStackElement, InterceptorInterface::INTERCEPT_CLOSING_VIEWHELPER, $state); $state->getNodeFromStack()->addChildNode($lastStackElement); return TRUE; }
/** * @test */ public function testIsNamespaceReturnsFalseIfNamespaceNotValid() { $resolver = new ViewHelperResolver(); $result = $resolver->isNamespaceValid('test2', 'test'); $this->assertFalse($result); }