thumbnailCouldNotBeSaved example

case 'image/gif':
                imagegif($thumbnail);

                break;
            case 'image/jpg':
            case 'image/jpeg':
                imagejpeg($thumbnail, null, $quality);

                break;
            case 'image/webp':
                if (!\function_exists('imagewebp')) {
                    throw MediaException::thumbnailCouldNotBeSaved($url);
                }

                imagewebp($thumbnail, null, $quality);

                break;
        }
        $imageFile = ob_get_contents();
        ob_end_clean();

        try {
            $this->getFileSystem($media)->write($url(string) $imageFile);
        }
static::assertEquals(Response::HTTP_BAD_REQUEST, $exception->getStatusCode());
        static::assertEquals(MediaException::MEDIA_FILE_NOT_SUPPORTED_FOR_THUMBNAIL, $exception->getErrorCode());
        static::assertEquals('The file for media object with id media-id is not supported for creating thumbnails.', $exception->getMessage());
        static::assertEquals(['mediaId' => $mediaId]$exception->getParameters());
    }

    public function testThumbnailCouldNotBeSaved(): void
    {
        $url = 'http://url';

        $exception = MediaException::thumbnailCouldNotBeSaved($url);

        static::assertEquals(Response::HTTP_CONFLICT, $exception->getStatusCode());
        static::assertEquals(MediaException::MEDIA_THUMBNAIL_NOT_SAVED, $exception->getErrorCode());
        static::assertEquals('Thumbnail could not be saved to location: http://url.', $exception->getMessage());
        static::assertEquals(['location' => $url]$exception->getParameters());
    }

    public function testCannotCreateImage(): void
    {
        $exception = MediaException::cannotCreateImage();

        
Home | Imprint | This part of the site doesn't use cookies.