/** * @expectedException \OCA\Gallery\Service\InternalServerErrorServiceException */ public function testPreviewValidatorWithBrokenSetup() { $square = true; $base64Encode = true; $this->mockPreviewValidatorWithBrokenSystem(); $this->service->previewValidator($square, $base64Encode); }
/** * @expectedException \OCA\Gallery\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)) { $preview = $this->previewService->createPreview($file, $width, $height, $keepAspect, $base64Encode); } else { $preview = $this->downloadService->downloadFile($file, $base64Encode); } if (!$preview) { list($preview, $status) = $this->getErrorData(); } return [$preview, $status]; }
/** * @param File $file * @param int $width * @param int $height * @param bool $keepAspect * @param bool $base64Encode */ private function mockCreatePreviewThrowsException($file, $width, $height, $keepAspect, $base64Encode) { $exception = new InternalServerErrorServiceException('Encryption ate your file'); $this->previewService->expects($this->once())->method('createPreview')->with($this->equalTo($file), $this->equalTo($width), $this->equalTo($height), $this->equalTo($keepAspect), $this->equalTo($base64Encode))->willthrowException($exception); }
/** * @param $square * @param $base64Encode * @param $base64EncodedPreview */ private function mockPreviewValidator($square, $base64Encode, $base64EncodedPreview) { $this->previewService->expects($this->once())->method('previewValidator')->with($square, $base64Encode)->willReturn($base64EncodedPreview); }