예제 #1
0
 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);
 }
예제 #2
0
 private function setPageStatus(Page $page, array $requestAttributes)
 {
     if (isset($requestAttributes['status'])) {
         $page->setStatus(PageStatusValue::get($requestAttributes['status']));
     }
 }
예제 #3
0
 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);
 }
예제 #4
0
 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));
 }
예제 #5
0
 public function it_can_provide_blocks_relationship()
 {
     $this->page->setBlocks([]);
     $this->getRelationship($this->page, PageBlock::TYPE)->shouldHaveType(Relationship::class);
 }
예제 #6
0
 public function let(Page $page)
 {
     $this->block = (new PageBlock(Uuid::uuid4(), $page->getWrappedObject(), 'type', ['answer' => 42], 'main', 42, PageStatusValue::get(PageStatusValue::PUBLISHED)))->metaDataSetInsertTimestamp(new \DateTimeImmutable())->metaDataSetUpdateTimestamp(new \DateTimeImmutable());
 }