/** * It should not register on PERSIST when there is already a document. */ public function testHandleRegisterPersistAlreadyExists() { $this->persistEvent->getDocument()->willReturn($this->document); $this->persistEvent->getNode()->willReturn($this->node->reveal()); $this->persistEvent->getLocale()->willReturn('fr'); $this->registry->registerDocument($this->document, $this->node->reveal(), 'fr')->shouldNotBeCalled(); $this->registry->updateLocale($this->document, 'fr')->shouldBeCalled(); $this->registry->hasDocument($this->document)->willReturn(true); $this->subscriber->handlePersist($this->persistEvent->reveal()); }
/** * It should set the parent document. */ public function testSetParentDocument() { $this->persistEvent->getDocument()->willReturn($this->document->reveal()); $this->persistEvent->getLocale()->willReturn('fr'); $this->metadataFactory->getMetadataForClass(get_class($this->document->reveal()))->willReturn($this->metadata->reveal()); $this->metadata->getAlias()->willReturn('test'); $this->nodeManager->createPath('/')->willReturn($this->parentNode->reveal()); $this->persistEvent->hasParentNode()->shouldBeCalled(); $this->persistEvent->setParentNode($this->parentNode->reveal())->shouldBeCalled(); $this->documentManager->find('/test', 'fr')->willReturn($this->parentDocument); $this->subscriber->handlePersist($this->persistEvent->reveal()); }