/** * Returns true if the passed mime type is supported * * In case of a failure, we just return that the media type is not supported * * @param string $mimeType * * @return boolean */ private function isMimeSupported($mimeType = '*') { try { return $this->previewManager->isMimeSupported($mimeType); } catch (\Exception $exception) { unset($exception); return false; } }
/** * Without a defined datadirectory, the thumbnail can't be saved and the original preview will * be used * * Ideally, Image->save should be mocked, but the mock is never called */ public function testPreviewValidatorWhenCannotSaveThumbnail() { $maxWidth = $width = 400; $maxHeight = $height = 200; $width = 500; $height = 100; $square = false; $fileId = 12345; $file = $this->mockFile($fileId); self::invokePrivate($this->previewManager, 'file', [$file]); self::invokePrivate($this->previewManager, 'dims', [[$maxWidth, $maxHeight]]); $preview = $this->mockGetPreview($fileId, $width, $height); self::invokePrivate($this->previewManager, 'preview', [$preview]); $response = $this->previewManager->previewValidator($square); $this->assertEquals([$width, $height], [$response->width(), $response->height()]); }
private function mockPreviewValidatorWithBrokenSystem() { $this->previewManager->expects($this->once())->method('previewValidator')->with($this->anything())->willThrowException(new \Exception('Boom')); }
private function mockIsMimeSupportedWithBrokenSystem($mimeType) { $this->previewManager->expects($this->once())->method('isMimeSupported')->with($mimeType)->willThrowException(new \Exception('Boom')); }