예제 #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()]);
 }
예제 #2
0
 /**
  * Makes sure we return previews of the asked dimensions and fix the cache
  * if necessary
  *
  * @param bool $square
  * @param bool $base64Encode
  *
  * @return \OC_Image|string
  */
 public function previewValidator($square, $base64Encode)
 {
     $preview = $this->previewManager->previewValidator($square);
     if ($base64Encode) {
         $preview = $this->encode($preview);
     }
     return $preview;
 }
예제 #3
0
 /**
  * Makes sure we return previews of the asked dimensions and fix the cache
  * if necessary
  *
  * @param bool $square
  * @param bool $base64Encode
  *
  * @return \OC_Image|string
  * @throws InternalServerErrorServiceException
  */
 public function previewValidator($square, $base64Encode)
 {
     try {
         $preview = $this->previewManager->previewValidator($square);
         if ($base64Encode) {
             $preview = $this->encode($preview);
         }
         return $preview;
     } catch (\Exception $exception) {
         throw new InternalServerErrorServiceException('There was an error while trying to fix the preview');
     }
 }
예제 #4
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()]);
 }