protected function setUp() { parent::setUp(); $this->contentMapper = $this->prophesize('Sulu\\Component\\Content\\Mapper\\ContentMapperInterface'); $this->requestAnalyzer = $this->prophesize('Sulu\\Component\\Webspace\\Analyzer\\RequestAnalyzerInterface'); $this->contentTypeManager = $this->prophesize('Sulu\\Component\\Content\\ContentTypeManagerInterface'); $this->structureManager = $this->prophesize('Sulu\\Component\\Content\\Compat\\StructureManagerInterface'); $this->sessionManager = $this->prophesize('Sulu\\Component\\PHPCR\\SessionManager\\SessionManagerInterface'); $this->session = $this->prophesize('PHPCR\\SessionInterface'); $this->node = $this->prophesize('PHPCR\\NodeInterface'); $this->parentNode = $this->prophesize('PHPCR\\NodeInterface'); $this->startPageNode = $this->prophesize('PHPCR\\NodeInterface'); $webspace = new Webspace(); $webspace->setKey('sulu_test'); $locale = new Localization(); $locale->setCountry('us'); $locale->setLanguage('en'); $this->requestAnalyzer->getWebspace()->willReturn($webspace); $this->requestAnalyzer->getCurrentLocalization()->willReturn($locale); $this->contentTypeManager->get('text_line')->willReturn(new TextLine('')); $this->sessionManager->getSession()->willReturn($this->session->reveal()); $this->sessionManager->getContentNode('sulu_test')->willReturn($this->startPageNode->reveal()); $this->session->getNodeByIdentifier('123-123-123')->willReturn($this->node->reveal()); $this->session->getNodeByIdentifier('321-321-321')->willReturn($this->parentNode->reveal()); $this->node->getIdentifier()->willReturn('123-123-123'); $this->node->getParent()->willReturn($this->parentNode->reveal()); $this->node->getDepth()->willReturn(4); $this->parentNode->getIdentifier()->willReturn('321-321-321'); $this->parentNode->getDepth()->willReturn(3); $this->startPageNode->getDepth()->willReturn(3); $this->structureResolver = new StructureResolver($this->contentTypeManager->reveal(), $this->structureManager->reveal()); }
/** * Return either the next or previous sibling of the given node * according to the $previous flag. * * @param NodeInterface $node * @param bool $previous * * @return NodeInterface|null * * @throws \RuntimeException */ private function getSiblingNode(NodeInterface $node, $previous = false) { $parentNode = $node->getParent(); $children = $parentNode->getNodes(); $previousNode = null; while ($child = current($children)) { if ($child->getPath() === $node->getPath()) { return $previous ? $previousNode : next($children); } $previousNode = $child; next($children); } throw new \RuntimeException(sprintf('Could not find node with path "%s" as a child of "%s". This should not happen', $node->getPath(), $parentNode->getPath())); }
/** * TODO: This is a workaround for a bug in Jackalope which will be fixed in the next * release 1.2: https://github.com/jackalope/jackalope/pull/262. */ private function rename(NodeInterface $node, $name) { $names = (array) $node->getParent()->getNodeNames(); $pos = array_search($node->getName(), $names); $next = isset($names[$pos + 1]) ? $names[$pos + 1] : null; $node->rename($name); if ($next) { $node->getParent()->orderBefore($name, $next); } }
/** * {@inheritdoc} */ public function getParent() { return $this->node->getParent(); }
/** * @expectedException \PHPCR\ItemNotFoundException */ public function testGetParentRootnode() { $this->rootNode->getParent(); }
/** * @see \PHPCR\NodeInterface::getParent */ public function getParent() { return new Node($this->node->getParent()); }
private function mapParent($document, NodeInterface $node) { // TODO: performance warning: We are eagerly fetching the parent node $targetNode = $node->getParent(); // Do not map non-referenceable parent nodes if (!$targetNode->hasProperty('jcr:uuid')) { return; } $document->setParent($this->proxyFactory->createProxyForNode($document, $targetNode)); }