/** * Export the given $site to the XMLWriter * * @param Site $site * @param string $nodeTypeFilter * @return void */ protected function exportSite(Site $site, $nodeTypeFilter) { /** @var ContentContext $contentContext */ $contentContext = $this->contextFactory->create(array('currentSite' => $site, 'invisibleContentShown' => true, 'inaccessibleContentShown' => true)); $siteNode = $contentContext->getCurrentSiteNode(); $this->xmlWriter->startElement('site'); $this->xmlWriter->writeAttribute('name', $site->getName()); $this->xmlWriter->writeAttribute('state', $site->getState()); $this->xmlWriter->writeAttribute('siteResourcesPackageKey', $site->getSiteResourcesPackageKey()); $this->xmlWriter->writeAttribute('siteNodeName', $siteNode->getName()); $this->nodeExportService->export($siteNode->getPath(), $contentContext->getWorkspaceName(), $this->xmlWriter, false, false, $this->resourcesPath, $nodeTypeFilter); $this->xmlWriter->endElement(); }
/** * @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')); }