/** * @test */ public function removedNodeWithoutExistingTargetNodeDataWillBeRemovedWhenPublished() { $homepageNode = $this->rootNode->createNode('homepage'); $homepageNode->remove(); $this->rootNode->getWorkspace()->publish($this->liveWorkspace); $this->saveNodesAndTearDownRootNodeAndRepository(); $this->setUpRootNodeAndRepository(); $liveContext = $this->contextFactory->create(array('workspaceName' => 'live', 'removedContentShown' => true)); $liveRootNode = $liveContext->getRootNode(); $liveHomepageNode = $liveRootNode->getNode('homepage'); $this->assertTrue($liveHomepageNode === null, 'A removed node should be removed after publishing, but it was still found'); }
/** * 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)); }
/** * @test */ public function aSingleNodeExportedWithNodeDataExportCanBeImportedWithNodeDataImport() { $originalNode = $this->rootNode->createNode('foo', $this->nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:ImportExport')); $originalNode->setProperty('description', 'Some node with a property'); $originalNode->setProperty('someDate', new \DateTime()); $this->persistenceManager->persistAll(); $exportService = new NodeExportService(); $xml = $exportService->export('/')->outputMemory(); $this->nodeDataRepository->removeAll(); $this->workspaceRepository->removeAll(); $this->saveNodesAndTearDownRootNodeAndRepository(); $this->setUpRootNodeAndRepository(); $importService = new NodeImportService(); $reader = new \XMLReader(); $reader->XML($xml); $importService->import($reader, '/'); $importedNode = $this->rootNode->getNode('foo'); $this->assertNotNull($importedNode, 'Expected node not found'); $this->assertSame($originalNode->getIdentifier(), $importedNode->getIdentifier()); $this->assertSame($originalNode->getProperty('description'), $importedNode->getProperty('description')); $this->assertEquals($originalNode->getProperty('someDate'), $importedNode->getProperty('someDate')); }
/** * @test */ public function nodeFromLiveWorkspaceMovedInUserWorkspaceRetainsShadowNodeInGroupWorkspace() { $liveContext = $this->contextFactory->create([]); $liveContext->getRootNode()->createNode('foo')->createNode('bar')->createNode('baz'); $this->persistenceManager->persistAll(); $this->rootNode->getNode('foo/bar/baz')->moveInto($this->rootNode->getNode('foo')); $this->persistenceManager->persistAll(); $this->rootNode->getContext()->getWorkspace()->publish($this->groupWorkspace); $this->persistenceManager->persistAll(); $groupContext = $this->contextFactory->create(['workspaceName' => $this->currentGroupWorkspace]); $movedBazNode = $groupContext->getRootNode()->getNode('foo')->getNode('baz'); $this->assertInstanceOf(NodeInterface::class, $movedBazNode); $shadowNode = $this->nodeDataRepository->findShadowNodeByPath('/foo/bar/baz', $this->groupWorkspace, $groupContext->getDimensions()); $this->assertInstanceOf(NodeData::class, $shadowNode); $this->assertNotNull($shadowNode->getMovedTo()); $this->assertTrue($shadowNode->isRemoved()); }
/** * Deletes the specified node and all of its sub nodes * * We need to call persistAll() in order to return the nextUri. We can't persist only the nodes in NodeDataRepository * because they might be connected to images / resources which need to be removed at the same time. * * @param Node $node * @return void */ public function deleteAction(Node $node) { if ($this->request->getHttpRequest()->isMethodSafe() === false) { $this->persistenceManager->persistAll(); } $q = new FlowQuery(array($node)); $node->remove(); $closestDocumentNode = $q->closest('[instanceof Neos.Neos:Document]')->get(0); $nextUri = $this->uriBuilder->reset()->setFormat('html')->setCreateAbsoluteUri(true)->uriFor('show', array('node' => $closestDocumentNode), 'Frontend\\Node', 'Neos.Neos'); $this->view->assign('value', array('data' => array('nextUri' => $nextUri), 'success' => true)); }
/** * @test */ public function getIdentifierReturnsTheIdentifier() { $nodeData = $this->getMockBuilder(NodeData::class)->disableOriginalConstructor()->getMock(); $nodeData->expects($this->once())->method('getIdentifier')->will($this->returnValue('theidentifier')); $context = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock(); $contextualizedNode = new Node($nodeData, $context); $this->assertEquals('theidentifier', $contextualizedNode->getIdentifier()); }