Ejemplo n.º 1
0
 public function it_can_delete_a_collection(ConfigCollection $collection)
 {
     $uuid = Uuid::uuid4();
     $collection->getUuid()->willReturn($uuid);
     $this->objectRepository->delete(ConfigCollection::TYPE, $uuid)->shouldBeCalled();
     $this->delete($collection);
 }
Ejemplo n.º 2
0
 public function it_can_will_error_and_roll_back_when_delete_fails(File $file)
 {
     $uuid = Uuid::uuid4();
     $file->getUuid()->willReturn($uuid);
     $this->pdo->beginTransaction()->shouldBeCalled();
     $this->fileSystem->delete($uuid->toString())->willReturn(false);
     $this->objectRepository->delete(File::TYPE, $uuid)->shouldNotBeCalled();
     $this->pdo->rollBack()->shouldBeCalled();
     $this->shouldThrow(\RuntimeException::class)->duringDelete($file);
 }
Ejemplo n.º 3
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));
 }
Ejemplo n.º 4
0
 public function it_can_delete_a_block_from_a_page(Page $page, PageBlock $block)
 {
     $uuid = Uuid::uuid4();
     $page->getUuid()->willReturn($uuid);
     $page->removeBlock($block)->shouldBeCalled();
     $page->metaDataSetUpdateTimestamp(new Argument\Token\TypeToken(\DateTimeImmutable::class))->shouldBeCalled();
     $blockUuid = Uuid::uuid4();
     $block->getUuid()->willReturn($blockUuid);
     $block->getPage()->willReturn($page);
     $block->setStatus(PageStatusValue::get('deleted'))->shouldBeCalled();
     $this->objectRepository->delete(PageBlock::TYPE, $blockUuid)->shouldBeCalled();
     $this->objectRepository->update(Page::TYPE, $uuid)->shouldBeCalled();
     $this->deleteBlockFromPage($block, $page);
 }
Ejemplo n.º 5
0
 public function delete(File $file)
 {
     $this->pdo->beginTransaction();
     try {
         if (!$this->fileSystem->delete($file->getUuid()->toString())) {
             throw new \RuntimeException('Failed to delete file');
         }
         $this->objectRepository->delete(File::TYPE, $file->getUuid());
         $this->pdo->commit();
     } catch (\Throwable $exception) {
         $this->pdo->rollBack();
         throw $exception;
     }
 }
Ejemplo n.º 6
0
 public function delete(User $user)
 {
     // The database constraint should cascade the delete to the page
     $this->objectRepository->delete(User::TYPE, $user->getUuid());
 }
Ejemplo n.º 7
0
 public function delete(ConfigCollection $collection)
 {
     // The database constraint should cascade the delete to the collection and its items
     $this->objectRepository->delete(ConfigCollection::TYPE, $collection->getUuid());
 }
Ejemplo n.º 8
0
 public function it_can_delete_a_user(User $user)
 {
     $user->getUuid()->willReturn($uuid = Uuid::uuid4());
     $this->objectRepository->delete(User::TYPE, $uuid);
     $this->delete($user);
 }