Exemplo n.º 1
0
 public function it_can_execute_request_with_null_parent(RequestInterface $request, Page $page1, Page $page2)
 {
     $parentUuid = null;
     $page1Uuid = Uuid::uuid4();
     $page1->getUuid()->willReturn($page1Uuid);
     $page1->getParentUuid()->willReturn(null);
     $page1->getSortOrder()->willReturn(1);
     $page1->setSortOrder(2)->shouldBeCalled();
     $page2Uuid = Uuid::uuid4();
     $page2->getUuid()->willReturn($page2Uuid);
     $page2->getParentUuid()->willReturn(null);
     $page2->getSortOrder()->willReturn(2);
     $page2->setSortOrder(1)->shouldBeCalled();
     $this->pageRepository->getByUuid($page1Uuid)->willReturn($page1);
     $this->pageRepository->getByUuid($page2Uuid)->willReturn($page2);
     $this->pageRepository->update($page1)->shouldBeCalled();
     $this->pageRepository->update($page2)->shouldBeCalled();
     $orderedPageUuids = [['page_uuid' => $page2Uuid->toString()], ['page_uuid' => $page1Uuid->toString()]];
     $request->getAcceptContentType()->willReturn('*/*');
     $request->offsetGet('ordered_pages')->willReturn($orderedPageUuids);
     $request->offsetGet('parent_uuid')->willReturn($parentUuid);
     $response = $this->executeRequest($request);
     $response->shouldHaveType(ResponseInterface::class);
     $response['data']->shouldBe([$page2, $page1]);
 }
Exemplo n.º 2
0
 private function setPageSortOrder(Page $page, array $requestAttributes)
 {
     if (isset($requestAttributes['sort_order'])) {
         $page->setSortOrder($requestAttributes['sort_order']);
     }
 }