/** * @expectedException \OCA\GalleryPlus\Service\InternalServerErrorServiceException */ public function testCreatePreviewWithBrokenSystem() { /** @type File $file */ $file = $this->mockJpgFile(12345); $this->mockGetUserIdFails(); $this->service->createPreview($file, $maxX = 0, $maxY = 0, $keepAspect = true, $base64Encode = false); }
/** * @param File $file * @param bool $animatedPreview * @param int $width * @param int $height * @param bool $keepAspect * @param bool $base64Encode * * @return array */ private function getPreviewData($file, $animatedPreview, $width, $height, $keepAspect, $base64Encode) { $status = Http::STATUS_OK; if ($this->previewService->isPreviewRequired($file, $animatedPreview)) { $type = 'preview'; $preview = $this->previewService->createPreview($file, $width, $height, $keepAspect, $base64Encode); } else { $type = 'download'; $preview = $this->downloadService->downloadFile($file, $base64Encode); } if (!$preview) { list($preview, $status, $type) = $this->getErrorData(); } return [$preview, $status, $type]; }
/** * @param $file * @param $previewRequired * @param $width * @param $height * @param $keepAspect * @param $base64Encode * * @return array */ private function getPreviewData($file, $previewRequired, $width, $height, $keepAspect, $base64Encode) { $status = Http::STATUS_OK; if ($previewRequired) { $type = 'preview'; $preview = $this->previewService->createPreview($file, $width, $height, $keepAspect, $base64Encode); } else { $type = 'download'; $preview = $this->downloadService->downloadFile($file, $base64Encode); } if (!$preview) { $type = 'error'; $status = Http::STATUS_INTERNAL_SERVER_ERROR; $preview = null; } return [$preview, $status, $type]; }