public function testGetPreviewWithWrongId() { $fileId = 99999; $width = 1024; $height = 768; $this->mockGetResourceFromId($fileId, false); $errorResponse = new JSONResponse(['message' => "I'm truly sorry, but we were unable to generate a preview for this file", 'success' => false], Http::STATUS_INTERNAL_SERVER_ERROR); $response = $this->controller->getPreview($fileId, $width, $height); $this->assertEquals($errorResponse->getStatus(), $response->getStatus()); $this->assertEquals($errorResponse->getData()['success'], $response->getData()['success']); }
public function testGetPreviewWithBrokenGif() { $fileId = 1234; $width = 1024; $height = 768; /** @type File $file */ $file = $this->mockAnimatedGifFile($fileId); $this->mockGetDataWithEmptyPreview($fileId, $file, $width, $height); $errorResponse = $this->jsonErrorMessage(Http::STATUS_INTERNAL_SERVER_ERROR); $response = $this->controller->getPreview($fileId, $width, $height); $this->assertEquals($errorResponse->getStatus(), $response->getStatus()); $this->assertEquals($errorResponse->getData()['success'], $response->getData()['success']); }