handleReorder() public method

Adjusts the order of the document and its siblings.
public handleReorder ( Sulu\Component\DocumentManager\Event\ReorderEvent $event )
$event Sulu\Component\DocumentManager\Event\ReorderEvent
Exemplo n.º 1
0
 /**
  * It should return early on REORDER if the document has no parent (i.e. if the document is the root document and this shoouldn't really happen).
  */
 public function testReorderNoParent()
 {
     $document = $this->prophesize(OrderBehavior::class);
     $reorderEvent = $this->prophesize(ReorderEvent::class);
     $reorderEvent->getDocument()->willReturn($document->reveal());
     $this->inspector->getParent($document->reveal())->willReturn(null);
     $this->subscriber->handleReorder($reorderEvent->reveal());
     $this->inspector->getChildren(Argument::any())->shouldNotHaveBeenCalled();
 }
Exemplo n.º 2
0
 public function testReorder()
 {
     $document = $this->prophesize(OrderBehavior::class);
     $reorderEvent = $this->prophesize(ReorderEvent::class);
     $reorderEvent->getDocument()->willReturn($document);
     $reorderEvent->getNode()->willReturn($this->node);
     $reorderEvent->getAccessor()->willReturn($this->accessor);
     $this->encoder->systemName('order')->willReturn('sys:order');
     $node2 = $this->prophesize(NodeInterface::class);
     $node3 = $this->prophesize(NodeInterface::class);
     $parentNode = $this->prophesize(NodeInterface::class);
     $parentNode->getNodes()->willReturn([$this->node, $node2, $node3]);
     $this->node->getParent()->willReturn($parentNode);
     $this->node->setProperty('sys:order', 10, PropertyType::LONG)->shouldBeCalled();
     $node2->setProperty('sys:order', 20, PropertyType::LONG)->shouldBeCalled();
     $node3->setProperty('sys:order', 30, PropertyType::LONG)->shouldBeCalled();
     $this->node->getPropertyValueWithDefault('sys:order', null)->willReturn(40);
     $this->accessor->set('suluOrder', 40)->shouldBeCalled();
     $this->subscriber->handleReorder($reorderEvent->reveal());
 }