예제 #1
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;
     }
 }
예제 #2
0
 public function it_can_give_an_entities_id()
 {
     $this->getId($this->file)->shouldReturn($this->file->getUuid()->toString());
 }
예제 #3
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);
 }