mediaContainsNoThumbnails example

private function thumbnailsAreGeneratable(MediaEntity $media): bool
    {
        return $media->getMediaType() instanceof ImageType
            && !$media->getMediaType()->is(ImageType::VECTOR_GRAPHIC)
            && !$media->getMediaType()->is(ImageType::ANIMATED)
            && !$media->getMediaType()->is(ImageType::ICON);
    }

    private function deleteAssociatedThumbnails(MediaEntity $media, Context $context): void
    {
        if (!$media->getThumbnails()) {
            throw MediaException::mediaContainsNoThumbnails();
        }

        $delete = $media->getThumbnails()->getIds();

        $delete = \array_values(\array_map(static fn (string $id) => ['id' => $id]$delete));

        $this->thumbnailRepository->delete($delete$context);
    }

    private function getFileSystem(MediaEntity $media): FilesystemOperator
    {
        
public function testCannotCreateImage(): void
    {
        $exception = MediaException::cannotCreateImage();

        static::assertEquals(Response::HTTP_INTERNAL_SERVER_ERROR, $exception->getStatusCode());
        static::assertEquals(MediaException::MEDIA_CANNOT_CREATE_IMAGE_HANDLE, $exception->getErrorCode());
        static::assertEquals('Can not create image handle.', $exception->getMessage());
    }

    public function testMediaContainsNoThumbnails(): void
    {
        $exception = MediaException::mediaContainsNoThumbnails();

        static::assertEquals(Response::HTTP_INTERNAL_SERVER_ERROR, $exception->getStatusCode());
        static::assertEquals(MediaException::MEDIA_CONTAINS_NO_THUMBNAILS, $exception->getErrorCode());
        static::assertEquals('Media contains no thumbnails.', $exception->getMessage());
    }

    public function testStrategyNotFound(): void
    {
        $strategyName = 'strategy-name';

        $exception = MediaException::strategyNotFound($strategyName);

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