Adjusts the order of the document and its siblings.
public handlePersist ( Sulu\Component\DocumentManager\Event\PersistEvent $event ) | ||
$event | Sulu\Component\DocumentManager\Event\PersistEvent |
/** * It should set the order on the document. */ public function testPersistOrder() { $this->node->getParent()->willReturn($this->parentNode->reveal()); $this->parentNode->getNodes()->willReturn([$this->node->reveal()]); $this->persistEvent->getAccessor()->willReturn($this->accessor->reveal()); $this->accessor->set('suluOrder', 20)->shouldBeCalled(); $this->subscriber->handlePersist($this->persistEvent->reveal()); }
public function testPersist() { $document = $this->prophesize(OrderBehavior::class); $this->persistEvent->getDocument()->willReturn($document); $this->encoder->systemName('order')->willReturn('sys:order'); $node1 = $this->prophesize(NodeInterface::class); $node2 = $this->prophesize(NodeInterface::class); $node3 = $this->prophesize(NodeInterface::class); $parentNode = $this->prophesize(NodeInterface::class); $parentNode->getNodes()->willReturn([$node1, $node2, $node3]); $this->node->hasProperty('sys:order')->willReturn(false); $this->node->getParent()->willReturn($parentNode); $this->node->setProperty('sys:order', 40, PropertyType::LONG)->shouldBeCalled(); $this->node->getPropertyValueWithDefault('sys:order', null)->willReturn(40); $this->accessor->set('suluOrder', 40)->shouldBeCalled(); $this->subscriber->handlePersist($this->persistEvent->reveal()); }