Beispiel #1
0
 /**
  * @dataProvider providesPreviewValidatorData
  */
 public function testPreviewValidator($maxWidth, $maxHeight, $width, $height, $square, $expectedWidth, $expectedHeight)
 {
     self::invokePrivate($this->previewManager, 'userId', ['tester']);
     $app = new Application();
     $dataDir = $app->getContainer()->getServer()->getConfig()->getSystemValue('datadirectory');
     self::invokePrivate($this->previewManager, 'dataDir', [$dataDir]);
     $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([$expectedWidth, $expectedHeight], [$response->width(), $response->height()]);
 }
Beispiel #2
0
 /**
  * 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;
     }
 }
Beispiel #3
0
 /**
  * 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 mockIsMimeSupportedWithBrokenSystem($mimeType)
 {
     $this->previewManager->expects($this->once())->method('isMimeSupported')->with($mimeType)->willThrowException(new \Exception('Boom'));
 }
 private function mockPreviewValidatorWithBrokenSystem()
 {
     $this->previewManager->expects($this->once())->method('previewValidator')->with($this->anything())->willThrowException(new \Exception('Boom'));
 }