createThumbnailFile example

/** * @dataProvider deleteThumbnailProvider */
    public function testDeleteThumbnail(bool $private): void
    {
        $service = $private ? 'shopware.filesystem.private' : 'shopware.filesystem.public';

        $mediaId = Uuid::randomHex();

        $media = $this->createThumbnailWithMedia($mediaId$private);

        $thumbnailPath = $this->createThumbnailFile($media$service);

        $thumbnailIds = $this->getContainer()->get('media_thumbnail.repository')
            ->searchIds(new Criteria(), Context::createDefaultContext());

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

        $this->getContainer()->get('media_thumbnail.repository')->delete($delete, Context::createDefaultContext());
        $this->runWorker();

        static::assertFalse($this->getFilesystem($service)->has($thumbnailPath));
    }

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