/**
  * Return the TypoScript value relative to this TypoScript object (with processors etc applied).
  *
  * Note that subsequent calls of tsValue() with the same TypoScript path will return the same values since the
  * first evaluated value will be cached in memory.
  *
  * @param string $path
  * @return mixed
  */
 protected function tsValue($path)
 {
     $fullPath = $this->path . '/' . $path;
     if (!isset($this->tsValueCache[$fullPath])) {
         $this->tsValueCache[$fullPath] = $this->tsRuntime->evaluate($fullPath, $this);
     }
     return $this->tsValueCache[$fullPath];
 }
 /**
  * Is it possile to render $node with $typoScriptPath?
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
  * @param string $typoScriptPath
  * @return boolean TRUE if $node can be rendered at $typoScriptPath
  */
 public function canRenderWithNodeAndPath(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node, $typoScriptPath)
 {
     $currentSiteNode = $this->nodeRepository->getContext()->getCurrentSiteNode();
     // TODO: find closest folder node from this node...
     $closestFolderNode = $node;
     $typoScriptConfiguration = $this->typoScriptService->getMergedTypoScriptObjectTree($currentSiteNode, $closestFolderNode);
     $typoScriptRuntime = new \TYPO3\TypoScript\Core\Runtime($typoScriptConfiguration, $this->controllerContext);
     return $typoScriptRuntime->canRender($typoScriptPath);
 }
 public function setUp()
 {
     $this->convertEmailLinks = $this->getAccessibleMock('Networkteam\\Neos\\MailObfuscator\\Typoscript\\ConvertEmailLinksImplementation', array('getValue'), array(), '', FALSE);
     $this->mockContext = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Service\\Context')->disableOriginalConstructor()->getMock();
     $this->mockContext->expects($this->any())->method('getWorkspaceName')->will($this->returnValue('live'));
     $this->mockNode = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface')->getMock();
     $this->mockNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContext));
     $this->mockTsRuntime = $this->getMockBuilder('TYPO3\\TypoScript\\Core\\Runtime')->disableOriginalConstructor()->getMock();
     $this->mockTsRuntime->expects($this->any())->method('getCurrentContext')->will($this->returnValue(array('node' => $this->mockNode)));
     $this->convertEmailLinks->_set('tsRuntime', $this->mockTsRuntime);
     $this->convertEmailLinks->_set('linkNameConverter', new \Networkteam\Neos\MailObfuscator\String\Converter\RewriteAtCharConverter());
     $this->convertEmailLinks->_set('mailToHrefConverter', new \Networkteam\Neos\MailObfuscator\String\Converter\Mailto2HrefObfuscatingConverter());
     srand(10);
 }
 /**
  * Handle an Exception thrown while rendering TypoScript
  *
  * @param string $typoScriptPath
  * @param \Exception $exception
  * @return string
  * @throws StopActionException|SecurityException
  */
 public function handleRenderingException($typoScriptPath, \Exception $exception)
 {
     if ($exception instanceof StopActionException || $exception instanceof SecurityException) {
         throw $exception;
     }
     if ($exception instanceof Exceptions\RuntimeException) {
         $typoScriptPath = $exception->getTypoScriptPath();
         $exception = $exception->getPrevious();
     }
     if ($this->exceptionDisablesCache($typoScriptPath, $exception)) {
         $this->runtime->setEnableContentCache(false);
     }
     $referenceCode = $exception instanceof \TYPO3\Flow\Exception ? $exception->getReferenceCode() : null;
     return $this->handle($typoScriptPath, $exception, $referenceCode);
 }
 /**
  * Renders the view
  *
  * @return string The rendered view
  * @throws \TYPO3\TYPO3\Exception if no node is given
  * @api
  */
 public function render()
 {
     $currentNode = isset($this->variables['value']) ? $this->variables['value'] : NULL;
     if (!$currentNode instanceof \TYPO3\TYPO3CR\Domain\Model\NodeInterface) {
         throw new \TYPO3\TYPO3\Exception('TypoScriptView needs a node as argument.', 1329736456);
     }
     // TODO: find closest folder node from this node...
     $closestFolderNode = $currentNode;
     $currentSiteNode = $this->nodeRepository->getContext()->getCurrentSiteNode();
     $typoScriptObjectTree = $this->typoScriptService->getMergedTypoScriptObjectTree($currentSiteNode, $closestFolderNode);
     $typoScriptRuntime = new Runtime($typoScriptObjectTree, $this->controllerContext);
     $typoScriptRuntime->pushContextArray(array('node' => $currentNode));
     $output = $typoScriptRuntime->render($this->typoScriptPath);
     $typoScriptRuntime->popContext();
     return $output;
 }
 public function setUp()
 {
     $this->pluginImplementation = $this->getAccessibleMock('TYPO3\\Neos\\TypoScript\\PluginImplementation', ['buildPluginRequest'], [], '', false);
     $this->mockHttpUri = $this->getMockBuilder('TYPO3\\Flow\\Http\\Uri')->disableOriginalConstructor()->getMock();
     $this->mockHttpUri->expects($this->any())->method('getHost')->will($this->returnValue('localhost'));
     $this->mockHttpRequest = $this->getMockBuilder('TYPO3\\Flow\\Http\\Request')->disableOriginalConstructor()->getMock();
     $this->mockHttpRequest->expects($this->any())->method('getUri')->will($this->returnValue($this->mockHttpUri));
     $this->mockActionRequest = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\ActionRequest')->disableOriginalConstructor()->getMock();
     $this->mockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->mockHttpRequest));
     $this->mockControllerContext = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\Controller\\ControllerContext')->disableOriginalConstructor()->getMock();
     $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockActionRequest));
     $this->mockTsRuntime = $this->getMockBuilder('TYPO3\\TypoScript\\Core\\Runtime')->disableOriginalConstructor()->getMock();
     $this->mockTsRuntime->expects($this->any())->method('getControllerContext')->will($this->returnValue($this->mockControllerContext));
     $this->pluginImplementation->_set('tsRuntime', $this->mockTsRuntime);
     $this->mockDispatcher = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\Dispatcher')->disableOriginalConstructor()->getMock();
     $this->pluginImplementation->_set('dispatcher', $this->mockDispatcher);
 }
 /**
  * @test
  */
 public function viewHelperRendersUriViaStringPointingToSubNodes()
 {
     $this->tsRuntime->pushContext('documentNode', $this->contentContext->getCurrentSiteNode()->getNode('home/about-us/mission'));
     $this->assertOutputLinkValid('en/home/about-us/history.html', $this->viewHelper->render('../history'));
     $this->tsRuntime->popContext();
     $this->assertOutputLinkValid('en/home/about-us/our-mission.html', $this->viewHelper->render('about-us/mission'));
     $this->assertOutputLinkValid('en/home/about-us/our-mission.html', $this->viewHelper->render('./about-us/mission'));
 }
 /**
  * @test
  */
 public function viewHelperRendersUriViaStringPointingToSubNodes()
 {
     $this->tsRuntime->pushContext('documentNode', $this->contentContext->getCurrentSiteNode()->getNode('home/about-us/mission'));
     $this->assertSame('<a href="/en/home/about-us/history.html">History</a>', $this->viewHelper->render('../history'));
     $this->tsRuntime->popContext();
     $this->assertSame('<a href="/en/home/about-us/our-mission.html">Our mission</a>', $this->viewHelper->render('about-us/mission'));
     $this->assertSame('<a href="/en/home/about-us/our-mission.html">Our mission</a>', $this->viewHelper->render('./about-us/mission'));
 }
 /**
  * @test
  * @dataProvider attributeExamples
  */
 public function evaluateTests($properties, $expectedOutput)
 {
     $path = 'attributes/test';
     $this->mockTsRuntime->expects($this->any())->method('evaluate')->will($this->returnCallback(function ($evaluatePath, $that) use($path, $properties) {
         $relativePath = str_replace($path . '/', '', $evaluatePath);
         return ObjectAccess::getPropertyPath($properties, str_replace('/', '.', $relativePath));
     }));
     $typoScriptObjectName = 'TYPO3.TypoScript:Attributes';
     $renderer = new AttributesImplementation($this->mockTsRuntime, $path, $typoScriptObjectName);
     if ($properties !== null) {
         foreach ($properties as $name => $value) {
             ObjectAccess::setProperty($renderer, $name, $value);
         }
     }
     $result = $renderer->evaluate();
     $this->assertEquals($expectedOutput, $result);
 }
 public function setUp()
 {
     $this->pluginImplementation = $this->getAccessibleMock(PluginImplementation::class, ['buildPluginRequest'], [], '', false);
     $this->mockHttpUri = $this->getMockBuilder(Uri::class)->disableOriginalConstructor()->getMock();
     $this->mockHttpUri->expects($this->any())->method('getHost')->will($this->returnValue('localhost'));
     $this->mockHttpRequest = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock();
     $this->mockHttpRequest->expects($this->any())->method('getUri')->will($this->returnValue($this->mockHttpUri));
     $this->mockActionRequest = $this->getMockBuilder(ActionRequest::class)->disableOriginalConstructor()->getMock();
     $this->mockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->mockHttpRequest));
     $this->mockControllerContext = $this->getMockBuilder(ControllerContext::class)->disableOriginalConstructor()->getMock();
     $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockActionRequest));
     $this->mockTsRuntime = $this->getMockBuilder(Runtime::class)->disableOriginalConstructor()->getMock();
     $this->mockTsRuntime->expects($this->any())->method('getControllerContext')->will($this->returnValue($this->mockControllerContext));
     $this->pluginImplementation->_set('tsRuntime', $this->mockTsRuntime);
     $this->mockDispatcher = $this->getMockBuilder(Dispatcher::class)->disableOriginalConstructor()->getMock();
     $this->pluginImplementation->_set('dispatcher', $this->mockDispatcher);
 }
 /**
  * @test
  * @dataProvider tagExamples
  */
 public function evaluateTests($properties, $attributes, $content, $expectedOutput)
 {
     $path = 'tag/test';
     $this->mockTsRuntime->expects($this->any())->method('evaluate')->will($this->returnCallback(function ($evaluatePath, $that) use($properties, $path, $attributes, $content) {
         $relativePath = str_replace($path . '/', '', $evaluatePath);
         switch ($relativePath) {
             case 'attributes':
                 return $attributes;
             case 'content':
                 return $content;
         }
         return isset($properties[$relativePath]) ? $properties[$relativePath] : NULL;
     }));
     $typoScriptObjectName = 'TYPO3.TypoScript:Tag';
     $renderer = new TagImplementation($this->mockTsRuntime, $path, $typoScriptObjectName);
     $result = $renderer->evaluate();
     $this->assertEquals($expectedOutput, $result);
 }
 public function setUp()
 {
     parent::setUp();
     $this->contentElementEditableService = new ContentElementEditableService();
     $this->mockPrivilegeManager = $this->getMockBuilder(PrivilegeManagerInterface::class)->getMock();
     $this->inject($this->contentElementEditableService, 'privilegeManager', $this->mockPrivilegeManager);
     $this->mockNodeAuthorizationService = $this->getMockBuilder(AuthorizationService::class)->getMock();
     $this->inject($this->contentElementEditableService, 'nodeAuthorizationService', $this->mockNodeAuthorizationService);
     $this->mockHtmlAugmenter = $this->getMockBuilder(HtmlAugmenter::class)->getMock();
     $this->inject($this->contentElementEditableService, 'htmlAugmenter', $this->mockHtmlAugmenter);
     $this->mockTsRuntime = $this->getMockBuilder('TYPO3\\TypoScript\\Core\\Runtime')->disableOriginalConstructor()->getMock();
     $this->mockContentContext = $this->getMockBuilder('TYPO3\\Neos\\Domain\\Service\\ContentContext')->disableOriginalConstructor()->getMock();
     $this->mockNode = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface')->getMock();
     $this->mockNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContentContext));
     $this->mockNode->expects($this->any())->method('getNodeType')->will($this->returnValue(new NodeType('Acme.Test:Headline', [], [])));
     $this->mockTsContext = array('node' => $this->mockNode);
     $this->mockTsRuntime->expects($this->any())->method('getCurrentContext')->will($this->returnValue($this->mockTsContext));
 }
 /**
  * @param NodeInterface $currentSiteNode
  * @return \TYPO3\TypoScript\Core\Runtime
  */
 protected function getTypoScriptRuntime(NodeInterface $currentSiteNode)
 {
     if ($this->typoScriptRuntime === null) {
         $this->typoScriptRuntime = $this->typoScriptService->createRuntime($currentSiteNode, $this->controllerContext);
         if (isset($this->options['enableContentCache']) && $this->options['enableContentCache'] !== null) {
             $this->typoScriptRuntime->setEnableContentCache($this->options['enableContentCache']);
         }
     }
     return $this->typoScriptRuntime;
 }
 /**
  * Render the given TypoScript and return the rendered page
  *
  * @return string
  */
 protected function renderTypoScript()
 {
     $this->typoScriptRuntime->pushContextArray($this->variables);
     try {
         $output = $this->typoScriptRuntime->render($this->getTypoScriptPathForCurrentRequest());
     } catch (RuntimeException $exception) {
         throw $exception->getPrevious();
     }
     $this->typoScriptRuntime->popContext();
     return $output;
 }
 public function setUp()
 {
     parent::setUp();
     $this->editableViewHelper = $this->getAccessibleMock('TYPO3\\Neos\\ViewHelpers\\ContentElement\\EditableViewHelper', array('renderChildren'));
     $this->mockPrivilegeManager = $this->getMockBuilder('TYPO3\\Flow\\Security\\Authorization\\PrivilegeManagerInterface')->getMock();
     $this->inject($this->editableViewHelper, 'privilegeManager', $this->mockPrivilegeManager);
     $this->mockNodeAuthorizationService = $this->getMockBuilder(AuthorizationService::class)->getMock();
     $this->inject($this->editableViewHelper, 'nodeAuthorizationService', $this->mockNodeAuthorizationService);
     $this->mockTemplateImplementation = $this->getMockBuilder('TYPO3\\TypoScript\\TypoScriptObjects\\TemplateImplementation')->disableOriginalConstructor()->getMock();
     $this->mockTsRuntime = $this->getMockBuilder('TYPO3\\TypoScript\\Core\\Runtime')->disableOriginalConstructor()->getMock();
     $this->mockContentContext = $this->getMockBuilder('TYPO3\\Neos\\Domain\\Service\\ContentContext')->disableOriginalConstructor()->getMock();
     $this->mockNode = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface')->getMock();
     $this->mockNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContentContext));
     $this->mockTsContext = array('node' => $this->mockNode);
     $this->mockTsRuntime->expects($this->any())->method('getCurrentContext')->will($this->returnValue($this->mockTsContext));
     $this->mockTemplateImplementation->expects($this->any())->method('getTsRuntime')->will($this->returnValue($this->mockTsRuntime));
     $this->mockView = $this->getAccessibleMock('TYPO3\\TypoScript\\TypoScriptObjects\\Helpers\\FluidView', array(), array(), '', FALSE);
     $this->mockView->expects($this->any())->method('getTypoScriptObject')->will($this->returnValue($this->mockTemplateImplementation));
     $this->editableViewHelper->initializeArguments();
 }
 /**
  * @test
  * @dataProvider responseHeadExamples
  */
 public function evaluateTests($httpVersion, $statusCode, $headers, $expectedOutput)
 {
     $path = 'responseHead/test';
     $this->mockTsRuntime->expects($this->any())->method('evaluate')->will($this->returnCallback(function ($evaluatePath) use($path, $httpVersion, $statusCode, $headers) {
         $relativePath = str_replace($path . '/', '', $evaluatePath);
         switch ($relativePath) {
             case 'httpVersion':
                 return $httpVersion;
             case 'statusCode':
                 return $statusCode;
             case 'headers':
                 return $headers;
         }
         return isset($properties[$relativePath]) ? $properties[$relativePath] : null;
     }));
     $typoScriptObjectName = 'TYPO3.TypoScript:Http.ResponseHead';
     $renderer = new \TYPO3\TypoScript\TypoScriptObjects\Http\ResponseHeadImplementation($this->mockTsRuntime, $path, $typoScriptObjectName);
     $result = $renderer->evaluate();
     $this->assertEquals($expectedOutput, $result);
 }
 public function setUp()
 {
     $this->convertUrisImplementation = $this->getAccessibleMock('TYPO3\\Neos\\TypoScript\\ConvertUrisImplementation', array('tsValue'), array(), '', false);
     $this->mockWorkspace = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\Workspace')->disableOriginalConstructor()->getMock();
     $this->mockContext = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Service\\Context')->disableOriginalConstructor()->getMock();
     $this->mockContext->expects($this->any())->method('getWorkspace')->will($this->returnValue($this->mockWorkspace));
     $this->mockNode = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface')->getMock();
     $this->mockNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContext));
     $this->mockHttpUri = $this->getMockBuilder('TYPO3\\Flow\\Http\\Uri')->disableOriginalConstructor()->getMock();
     $this->mockHttpUri->expects($this->any())->method('getHost')->will($this->returnValue('localhost'));
     $this->mockHttpRequest = $this->getMockBuilder('TYPO3\\Flow\\Http\\Request')->disableOriginalConstructor()->getMock();
     $this->mockHttpRequest->expects($this->any())->method('getUri')->will($this->returnValue($this->mockHttpUri));
     $this->mockActionRequest = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\ActionRequest')->disableOriginalConstructor()->getMock();
     $this->mockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->mockHttpRequest));
     $this->mockControllerContext = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\Controller\\ControllerContext')->disableOriginalConstructor()->getMock();
     $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockActionRequest));
     $this->mockLinkingService = $this->createMock('TYPO3\\Neos\\Service\\LinkingService');
     $this->convertUrisImplementation->_set('linkingService', $this->mockLinkingService);
     $this->mockTsRuntime = $this->getMockBuilder('TYPO3\\TypoScript\\Core\\Runtime')->disableOriginalConstructor()->getMock();
     $this->mockTsRuntime->expects($this->any())->method('getControllerContext')->will($this->returnValue($this->mockControllerContext));
     $this->convertUrisImplementation->_set('tsRuntime', $this->mockTsRuntime);
 }
 /**
  * @test
  * @dataProvider attributeExamples
  */
 public function evaluateTests($properties, $expectedOutput, $expectedOutputAsArray)
 {
     //		print_r(func_get_args());
     $path = 'attributes/test';
     $this->mockTsRuntime->expects($this->any())->method('evaluate')->will($this->returnCallback(function ($evaluatePath, $that) use($path, $properties) {
         $relativePath = str_replace($path . '/', '', $evaluatePath);
         return ObjectAccess::getPropertyPath($properties, str_replace('/', '.', $relativePath));
     }));
     $typoScriptObjectName = 'TYPO3.TypoScript:Attributes';
     $renderer = new AttributesImplementation($this->mockTsRuntime, $path, $typoScriptObjectName);
     if ($properties !== NULL) {
         foreach ($properties as $name => $value) {
             ObjectAccess::setProperty($renderer, $name, $value);
         }
     }
     $result = $renderer->evaluate();
     $this->assertInstanceOf('M12\\Foundation\\TypoScriptObjects\\AttributesImplementation', $result);
     $this->assertTrue(is_string($result->getAsString()));
     $this->assertTrue(is_array($result->getAsArray()));
     $this->assertEquals($expectedOutput, $result);
     $this->assertEquals($expectedOutput, $result->getAsString());
     $this->assertEquals($expectedOutputAsArray, $result->getAsArray());
 }
 /**
  * Iterates through all subelements.
  *
  * @return \ArrayIterator
  */
 public function getIterator()
 {
     $evaluatedArray = array();
     foreach ($this->partialTypoScriptTree as $key => $value) {
         if (!is_array($value)) {
             $evaluatedArray[$key] = $value;
         } elseif (isset($value['__objectType'])) {
             $evaluatedArray[$key] = $this->tsRuntime->evaluate($this->path . '/' . $key);
         } elseif (isset($value['__eelExpression'])) {
             $evaluatedArray[$key] = $this->tsRuntime->evaluate($this->path . '/' . $key, $this->templateImplementation);
         } else {
             $evaluatedArray[$key] = new TypoScriptPathProxy($this->templateImplementation, $this->path . '/' . $key, $this->partialTypoScriptTree[$key]);
         }
     }
     return new \ArrayIterator($evaluatedArray);
 }
 /**
  * Builds an array of string which must be used as tags for the cache entry identifier of a specific cached content segment.
  *
  * @param array $configuration
  * @param string $typoScriptPath
  * @param object $tsObject The actual TypoScript object
  * @return array
  */
 protected function buildCacheTags($configuration, $typoScriptPath, $tsObject)
 {
     $cacheTags = array();
     if (isset($configuration['entryTags'])) {
         foreach ($configuration['entryTags'] as $tagKey => $tagValue) {
             $tagValue = $this->runtime->evaluate($typoScriptPath . '/__meta/cache/entryTags/' . $tagKey, $tsObject);
             if (is_array($tagValue)) {
                 $cacheTags = array_merge($cacheTags, $tagValue);
             } elseif ((string) $tagValue !== '') {
                 $cacheTags[] = $tagValue;
             }
         }
     } else {
         $cacheTags = array(ContentCache::TAG_EVERYTHING);
     }
     return $cacheTags;
 }
 /**
  * @test
  */
 public function evaluateLocalizesFilenameIfLocalize()
 {
     $this->mockTsRuntime->expects($this->any())->method('evaluate')->will($this->returnCallback(function ($evaluatePath, $that) {
         $relativePath = str_replace('resourceUri/test/', '', $evaluatePath);
         switch ($relativePath) {
             case 'localize':
                 return true;
             case 'path':
                 return 'resource://Some.Package/Public/SomeResource';
             case 'package':
                 return 'Specified.Package';
         }
         return null;
     }));
     $this->mockI18nService->expects($this->atLeastOnce())->method('getLocalizedFilename')->will($this->returnValue(array('resource://Some.Package/Public/LocalizedFilename')));
     $this->mockResourceManager->expects($this->atLeastOnce())->method('getPublicPackageResourceUri')->will($this->returnValue('Static/Resources/Packages/Some.Package/LocalizedFilename'));
     $this->assertSame('Static/Resources/Packages/Some.Package/LocalizedFilename', $this->resourceUriImplementation->evaluate());
 }
 /**
  * Finally evaluate the TypoScript path
  *
  * As PHP does not like throwing an exception here, we render any exception using the configured TypoScript exception
  * handler and will also catch and log any exceptions resulting from that as a last resort.
  *
  * @return string
  */
 public function __toString()
 {
     try {
         return (string) $this->tsRuntime->evaluate($this->path);
     } catch (\Exception $exception) {
         try {
             return $this->tsRuntime->handleRenderingException($this->path, $exception);
         } catch (\Exception $exceptionHandlerException) {
             try {
                 // Throwing an exception in __toString causes a fatal error, so if that happens we catch them and use the context dependent exception handler instead.
                 $contextDependentExceptionHandler = new \TYPO3\TypoScript\Core\ExceptionHandlers\ContextDependentHandler();
                 $contextDependentExceptionHandler->setRuntime($this->tsRuntime);
                 return $contextDependentExceptionHandler->handleRenderingException($this->path, $exception);
             } catch (\Exception $contextDepndentExceptionHandlerException) {
                 $this->systemLogger->logException($contextDepndentExceptionHandlerException, array('path' => $this->path));
                 return sprintf('<!-- Exception while rendering exception in %s: %s (%s) -->', $this->path, $contextDepndentExceptionHandlerException->getMessage(), $contextDepndentExceptionHandlerException instanceof \TYPO3\Flow\Exception ? 'see reference code ' . $contextDepndentExceptionHandlerException->getReferenceCode() . ' in log' : $contextDepndentExceptionHandlerException->getCode());
             }
         }
     }
 }
 public function setUp()
 {
     $this->convertUrisImplementation = $this->getAccessibleMock(ConvertUrisImplementation::class, array('tsValue'), array(), '', false);
     $this->mockWorkspace = $this->getMockBuilder(Workspace::class)->disableOriginalConstructor()->getMock();
     $this->mockContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
     $this->mockContext->expects($this->any())->method('getWorkspace')->will($this->returnValue($this->mockWorkspace));
     $this->mockNode = $this->getMockBuilder(NodeInterface::class)->getMock();
     $this->mockNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContext));
     $this->mockHttpUri = $this->getMockBuilder(Uri::class)->disableOriginalConstructor()->getMock();
     $this->mockHttpUri->expects($this->any())->method('getHost')->will($this->returnValue('localhost'));
     $this->mockHttpRequest = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock();
     $this->mockHttpRequest->expects($this->any())->method('getUri')->will($this->returnValue($this->mockHttpUri));
     $this->mockActionRequest = $this->getMockBuilder(ActionRequest::class)->disableOriginalConstructor()->getMock();
     $this->mockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->mockHttpRequest));
     $this->mockControllerContext = $this->getMockBuilder(ControllerContext::class)->disableOriginalConstructor()->getMock();
     $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockActionRequest));
     $this->mockLinkingService = $this->createMock(LinkingService::class);
     $this->convertUrisImplementation->_set('linkingService', $this->mockLinkingService);
     $this->mockTsRuntime = $this->getMockBuilder(Runtime::class)->disableOriginalConstructor()->getMock();
     $this->mockTsRuntime->expects($this->any())->method('getControllerContext')->will($this->returnValue($this->mockControllerContext));
     $this->convertUrisImplementation->_set('tsRuntime', $this->mockTsRuntime);
 }
 public function setUp()
 {
     parent::setUp();
     $this->editableViewHelper = $this->getAccessibleMock(EditableViewHelper::class, array('renderChildren'));
     $this->mockPrivilegeManager = $this->getMockBuilder(PrivilegeManagerInterface::class)->getMock();
     $this->inject($this->editableViewHelper, 'privilegeManager', $this->mockPrivilegeManager);
     $this->mockNodeAuthorizationService = $this->getMockBuilder(AuthorizationService::class)->getMock();
     $this->inject($this->editableViewHelper, 'nodeAuthorizationService', $this->mockNodeAuthorizationService);
     $this->mockContentElementEditableService = $this->getMockBuilder(ContentElementEditableService::class)->getMock();
     $this->inject($this->editableViewHelper, 'contentElementEditableService', $this->mockContentElementEditableService);
     $this->mockTemplateImplementation = $this->getMockBuilder(TemplateImplementation::class)->disableOriginalConstructor()->getMock();
     $this->mockTsRuntime = $this->getMockBuilder(Runtime::class)->disableOriginalConstructor()->getMock();
     $this->mockContentContext = $this->getMockBuilder(ContentContext::class)->disableOriginalConstructor()->getMock();
     $this->mockNode = $this->getMockBuilder(NodeInterface::class)->getMock();
     $this->mockNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContentContext));
     $this->mockNode->expects($this->any())->method('getNodeType')->will($this->returnValue(new NodeType('Acme.Test:Headline', [], [])));
     $this->mockTsContext = array('node' => $this->mockNode);
     $this->mockTsRuntime->expects($this->any())->method('getCurrentContext')->will($this->returnValue($this->mockTsContext));
     $this->mockTemplateImplementation->expects($this->any())->method('getTsRuntime')->will($this->returnValue($this->mockTsRuntime));
     $this->mockView = $this->getAccessibleMock(FluidView::class, array(), array(), '', false);
     $this->mockView->expects($this->any())->method('getTypoScriptObject')->will($this->returnValue($this->mockTemplateImplementation));
     $this->editableViewHelper->initializeArguments();
 }
 /**
  * @test
  * @expectedException \TYPO3\TypoScript\Exception
  * @expectedExceptionCode 1395922119
  */
 public function evaluateWithCacheModeUncachedAndUnspecifiedContextThrowsException()
 {
     $mockControllerContext = $this->getMockBuilder(ControllerContext::class)->disableOriginalConstructor()->getMock();
     $runtime = new Runtime(array('foo' => array('bar' => array('__meta' => array('cache' => array('mode' => 'uncached'))))), $mockControllerContext);
     $runtime->evaluate('foo/bar');
 }
 /**
  * @test
  */
 public function renderPutsSiteNodeInTypoScriptContext()
 {
     $this->setUpMockView();
     $this->mockRuntime->expects($this->once())->method('pushContextArray')->with($this->arrayHasKey('site'));
     $this->mockView->render();
 }