public function it_errors_when_parent_doesnt_match_page(RequestInterface $request, Page $page1) { $parentUuid = Uuid::uuid4(); $page1Uuid = Uuid::uuid4(); $page1->getUuid()->willReturn($page1Uuid); $page1->getParentUuid()->willReturn(Uuid::uuid4()); $page1->getSortOrder()->willReturn(1); $this->pageRepository->getByUuid($page1Uuid)->willReturn($page1); $orderedPageUuids = [['page_uuid' => $page1Uuid->toString()]]; $request->getAcceptContentType()->willReturn('*/*'); $request->offsetGet('ordered_pages')->willReturn($orderedPageUuids); $request->offsetGet('parent_uuid')->willReturn($parentUuid->toString()); $this->shouldThrow(ResponseException::class)->duringExecuteRequest($request); }
public function deleteBlockFromPage(PageBlock $block, Page $page) { if (!$page->getUuid()->equals($block->getPage()->getUuid())) { throw new \OutOfBoundsException('PageBlock must belong to page to be added to it.'); } // The database constraint should cascade the delete to the page $this->objectRepository->delete(PageBlock::TYPE, $block->getUuid()); $page->removeBlock($block); $this->objectRepository->update(Page::TYPE, $page->getUuid()); $page->metaDataSetUpdateTimestamp(new \DateTimeImmutable()); $block->setStatus(PageStatusValue::get(PageStatusValue::DELETED)); }
public function it_will_error_when_trying_to_delete_a_block_from_wrong_page(Page $page1, Page $page2, PageBlock $block) { $uuid1 = Uuid::uuid4(); $page1->getUuid()->willReturn($uuid1); $uuid2 = Uuid::uuid4(); $page2->getUuid()->willReturn($uuid2); $block->getPage()->willReturn($page2); $this->shouldThrow(\OutOfBoundsException::class)->duringDeleteBlockFromPage($block, $page1); }
public function it_can_give_an_entities_id() { $this->getId($this->page)->shouldReturn($this->page->getUuid()->toString()); }