Ejemplo n.º 1
0
 public function it_can_execute_a_request(RequestInterface $request, Page $page)
 {
     $uuid = Uuid::uuid4();
     $attributes = ['type' => 'type', 'parameters' => ['content' => 1138], 'location' => 'main', 'sort_order' => 52, 'status' => PageStatusValue::CONCEPT];
     $request->offsetGet('id')->willReturn($uuid->toString());
     $request->offsetGet('attributes')->willReturn($attributes);
     $request->getAcceptContentType()->willReturn('application/json');
     $this->pageRepository->getByUuid($uuid)->willReturn($page);
     $this->blockTypeContainer->getType('type')->willReturn(new HtmlContentBlockType());
     $this->pageRepository->addBlockToPage(new Argument\Token\TypeToken(PageBlock::class), $page)->shouldBeCalled();
     $response = $this->executeRequest($request);
     $response->shouldHaveType(ResponseInterface::class);
     $response['data']->shouldHaveType(PageBlock::class);
     $response['includes']->shouldBe(['pages']);
 }
Ejemplo n.º 2
0
 public function it_can_execute_a_request_part_deux(RequestInterface $request, Page $page, PageBlock $pageBlock)
 {
     $pageUuid = Uuid::uuid4();
     $pageBlockUuid = Uuid::uuid4();
     $newStatus = PageStatusValue::get(PageStatusValue::DELETED);
     $request->offsetExists('page_uuid')->willReturn(true);
     $request->offsetGet('page_uuid')->willReturn($pageUuid->toString());
     $request->offsetExists('uuid')->willReturn(true);
     $request->offsetGet('uuid')->willReturn($pageBlockUuid->toString());
     $request->offsetExists('parameters')->willReturn(false);
     $request->offsetExists('sort_order')->willReturn(false);
     $request->offsetExists('status')->willReturn(true);
     $request->offsetGet('status')->willReturn($newStatus->toString());
     $request->getAcceptContentType()->willReturn('text/xml');
     $pageBlock->getType()->willReturn('type');
     $pageBlock->setStatus($newStatus)->shouldBeCalled();
     $this->pageRepository->getByUuid($pageUuid)->willReturn($page);
     $page->getBlockByUuid($pageBlockUuid)->willReturn($pageBlock);
     $pageBlock->getParameters()->willReturn(['content' => 'test']);
     $this->blockTypeContainer->getType('type')->willReturn(new HtmlContentBlockType());
     $this->pageRepository->updateBlockForPage($pageBlock, $page)->shouldBeCalled();
     $response = $this->executeRequest($request);
     $response['data']->shouldBe($pageBlock);
 }