/** * @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 */ public function wrapContentPropertyDoesNotAddEditingMetaDataIfEditNodePrivilegeIsNotGranted() { $this->mockContentContext->expects($this->atLeastOnce())->method('getWorkspaceName')->will($this->returnValue('not-live')); $this->mockPrivilegeManager->expects($this->atLeastOnce())->method('isPrivilegeTargetGranted')->with('TYPO3.Neos:Backend.GeneralAccess')->will($this->returnValue(true)); $this->mockNodeAuthorizationService->expects($this->atLeastOnce())->method('isGrantedToEditNode')->will($this->returnValue(false)); $this->mockHtmlAugmenter->expects($this->never())->method('addAttributes'); $this->contentElementEditableService->wrapContentProperty($this->mockNode, 'someProperty', '<div>someRenderedPropertyValue</div>'); }
/** * @test */ public function renderDoesNotAddEditingMetaDataIfEditNodePrivilegeIsNotGranted() { $this->templateVariables = array('someProperty' => 'somePropertyValue'); $this->mockContentContext->expects($this->atLeastOnce())->method('getWorkspaceName')->will($this->returnValue('not-live')); $this->mockPrivilegeManager->expects($this->atLeastOnce())->method('isPrivilegeTargetGranted')->with('TYPO3.Neos:Backend.GeneralAccess')->will($this->returnValue(true)); $this->mockNodeAuthorizationService->expects($this->atLeastOnce())->method('isGrantedToEditNode')->will($this->returnValue(false)); $this->tagBuilder->expects($this->never())->method('addAttribute'); $this->injectDependenciesIntoViewHelper($this->editableViewHelper); $this->injectTypoScriptObject(); $this->editableViewHelper->render('someProperty'); }
/** * Sets up a view with context for testing * * @return void */ public function setUpMockView() { $this->mockContext = $this->getMockBuilder(ContentContext::class)->disableOriginalConstructor()->getMock(); $mockNode = $this->getMockBuilder(NodeData::class)->disableOriginalConstructor()->getMock(); $this->mockContextualizedNode = $this->getMockBuilder(Node::class)->setMethods(array('getContext'))->setConstructorArgs(array($mockNode, $this->mockContext))->getMock(); $mockSiteNode = $this->createMock(NodeInterface::class); $this->mockContext->expects($this->any())->method('getCurrentSiteNode')->will($this->returnValue($mockSiteNode)); $this->mockContext->expects($this->any())->method('getDimensions')->will($this->returnValue(array())); $this->mockContextualizedNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContext)); $this->mockRuntime = $this->getMockBuilder(Runtime::class)->disableOriginalConstructor()->getMock(); $mockControllerContext = $this->getMockBuilder(ControllerContext::class)->disableOriginalConstructor()->getMock(); $this->mockSecurityContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock(); $mockTypoScriptService = $this->createMock(TypoScriptService::class); $mockTypoScriptService->expects($this->any())->method('createRuntime')->will($this->returnValue($this->mockRuntime)); $this->mockView = $this->getAccessibleMock(TypoScriptView::class, array('getClosestDocumentNode')); $this->mockView->expects($this->any())->method('getClosestDocumentNode')->will($this->returnValue($this->mockContextualizedNode)); $this->inject($this->mockView, 'controllerContext', $mockControllerContext); $this->inject($this->mockView, 'securityContext', $this->mockSecurityContext); $this->inject($this->mockView, 'typoScriptService', $mockTypoScriptService); $this->mockView->_set('variables', array('value' => $this->mockContextualizedNode)); }
/** * Sets up a view with context for testing * * @return void */ public function setUpMockView() { $this->mockContext = $this->getMock('TYPO3\\Neos\\Domain\\Service\\ContentContext', array(), array(), '', FALSE); $mockNode = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Model\\NodeData', array(), array(), '', FALSE); $this->mockContextualizedNode = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Model\\Node', NULL, array($mockNode, $this->mockContext)); $mockSiteNode = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface'); $this->mockContext->expects($this->any())->method('getCurrentSiteNode')->will($this->returnValue($mockSiteNode)); $this->mockContext->expects($this->any())->method('getDimensions')->will($this->returnValue(array())); $this->mockContextualizedNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContext)); $this->mockRuntime = $this->getMock('TYPO3\\TypoScript\\Core\\Runtime', array(), array(), '', FALSE); $mockControllerContext = $this->getMock('TYPO3\\Flow\\Mvc\\Controller\\ControllerContext', array(), array(), '', FALSE); $this->mockSecurityContext = $this->getMock('TYPO3\\Flow\\Security\\Context', array(), array(), '', FALSE); $mockTypoScriptService = $this->getMock('TYPO3\\Neos\\Domain\\Service\\TypoScriptService'); $mockTypoScriptService->expects($this->any())->method('createRuntime')->will($this->returnValue($this->mockRuntime)); $this->mockView = $this->getAccessibleMock('TYPO3\\Neos\\View\\TypoScriptView', array('getClosestDocumentNode')); $this->mockView->expects($this->any())->method('getClosestDocumentNode')->will($this->returnValue($this->mockContextualizedNode)); $this->inject($this->mockView, 'controllerContext', $mockControllerContext); $this->inject($this->mockView, 'securityContext', $this->mockSecurityContext); $this->inject($this->mockView, 'typoScriptService', $mockTypoScriptService); $this->mockView->_set('variables', array('value' => $this->mockContextualizedNode)); }
/** * Adopt (translate) the given node and parents that are not yet visible to the given context * * @param NodeInterface $node * @param ContentContext $contentContext * @param boolean $copyContent TRUE if the content from the nodes that are translated should be copied * @return void */ protected function adoptNodeAndParents(NodeInterface $node, ContentContext $contentContext, $copyContent) { $contentContext->adoptNode($node, $copyContent); $parentNode = $node; while ($parentNode = $parentNode->getParent()) { $visibleInContext = $contentContext->getNodeByIdentifier($parentNode->getIdentifier()) !== NULL; if ($parentNode->getPath() !== '/' && $parentNode->getPath() !== '/sites' && !$visibleInContext) { $contentContext->adoptNode($parentNode, $copyContent); } } }
/** * Adopt (translate) the given node and parents that are not yet visible to the given context * * @param NodeInterface $node * @param ContentContext $contentContext * @param boolean $copyContent TRUE if the content from the nodes that are translated should be copied * @return void */ protected function adoptNodeAndParents(NodeInterface $node, ContentContext $contentContext, $copyContent) { $contentContext->adoptNode($node, $copyContent); $parentNode = $node; while ($parentNode = $parentNode->getParent()) { $visibleInContext = $contentContext->getNodeByIdentifier($parentNode->getIdentifier()) !== null; if ($parentNode->getPath() !== '/' && $parentNode->getPath() !== SiteService::SITES_ROOT_PATH && !$visibleInContext) { $contentContext->adoptNode($parentNode, $copyContent); } } }
/** * @test */ public function linkingServiceCreatesUriViaStringPointingToSubNodes() { $this->assertOutputLinkValid('en/home/about-us/history.html', $this->linkingService->createNodeUri($this->controllerContext, '../history', $this->contentContext->getCurrentSiteNode()->getNode('home/about-us/mission'))); $this->assertOutputLinkValid('en/home/about-us/our-mission.html', $this->linkingService->createNodeUri($this->controllerContext, 'about-us/mission', $this->baseNode)); $this->assertOutputLinkValid('en/home/about-us/our-mission.html', $this->linkingService->createNodeUri($this->controllerContext, './about-us/mission', $this->baseNode)); }
/** * Find all nodes of a specific node type * * @param string $nodeType * @param ContentContext $context current content context, see class doc comment for details * @return array<NodeInterface> all nodes of type $nodeType in the current $context */ protected function getNodes($nodeType, ContentContext $context) { $nodes = array(); $siteNode = $context->getCurrentSiteNode(); foreach ($this->nodeDataRepository->findByParentAndNodeTypeRecursively($siteNode->getPath(), $nodeType, $context->getWorkspace()) as $nodeData) { $nodes[] = $this->nodeFactory->createFromNodeData($nodeData, $context); } return $nodes; }
/** * @param ContentContext $contentContext * @return void */ public function initializeContentContext(ContentContext $contentContext) { if ($contentContext->getCurrentSite()) { $this->contentContext = $contentContext; } }