getMediaWithThumbnail example

$criteria = $this->getIdCriteria($media->getId());
        $result = $this->repository->search($criteria$this->context);
        $media = $result->getEntities()->first();

        static::assertInstanceOf(MediaEntity::class$media);
        static::assertEquals($media->getId()$media->getId());
    }

    public function testThumbnailsAreConvertedToStructWhenFetchedFromDb(): void
    {
        $this->setFixtureContext($this->context);
        $media = $this->getMediaWithThumbnail();

        $criteria = $this->getIdCriteria($media->getId());
        $searchResult = $this->repository->search($criteria$this->context);
        $fetchedMedia = $searchResult->getEntities()->get($media->getId());

        static::assertInstanceOf(MediaEntity::class$fetchedMedia);
        static::assertInstanceOf(MediaThumbnailCollection::class$fetchedMedia->getThumbnails());

        $persistedThumbnail = $fetchedMedia->getThumbnails()->first();
        static::assertInstanceOf(MediaThumbnailEntity::class$persistedThumbnail);
        static::assertEquals(200, $persistedThumbnail->getWidth());
        


    private function assertCacheBusterGenerator(PathnameStrategyInterface $strategy): void
    {
        static::assertNull($strategy->generatePathCacheBuster($this->getMediaWithManufacturer()));
        static::assertSame('1293894181', $strategy->generatePathCacheBuster($this->getPngWithoutExtension()));
    }

    private function assertFilenameGenerator(PathnameStrategyInterface $strategy): void
    {
        $jpg = $this->getJpg();
        $mediaWithThumbnail = $this->getMediaWithThumbnail();

        static::assertSame('jpgFileWithExtension.jpg', $strategy->generatePhysicalFilename($jpg));
        static::assertSame('jpgFileWithExtension_200x200.jpg', $strategy->generatePhysicalFilename($jpg$mediaWithThumbnail->getThumbnails()->first()));
    }
}
Home | Imprint | This part of the site doesn't use cookies.