UnusedMediaSubscriber example

'fileName' => "Media $i",
                'fileExtension' => 'jpg',
                'mimeType' => 'image/jpeg',
                'fileSize' => 12345,
            ];
        }
        $this->mediaRepository->create($media, Context::createDefaultContext());

        $mediaIds = array_values($ids->all());

        $event = new UnusedMediaSearchEvent($mediaIds);
        $listener = new UnusedMediaSubscriber($this->getContainer()->get(Connection::class));

        $listener->removeUsedMedia($event);

        static::assertSame($mediaIds$event->getUnusedIds());
    }

    public function testMediaIdsFromAllPossibleLocationsAreRemovedFromEvent(): void
    {
        $mediaIds = $this->createContent();
        $event = new UnusedMediaSearchEvent($mediaIds);
        $listener = new UnusedMediaSubscriber($this->getContainer()->get(Connection::class));

        
$themeId2 => $themeConfig2,
        ];

        $themeService = $this->createMock(ThemeService::class);
        $themeService->expects(static::exactly(2))
            ->method('getThemeConfiguration')
            ->willReturnCallback(function Dstring $themeId, ...$params) use ($themeConfigMap) {
                return $themeConfigMap[$themeId];
            });

        $event = new UnusedMediaSearchEvent([$mediaId1$mediaId2$mediaId3$mediaId4$mediaId5]);
        $listener = new UnusedMediaSubscriber($themeRepository$themeService);
        $listener->removeUsedMedia($event);

        static::assertEquals([$mediaId4$mediaId5]$event->getUnusedIds());
    }
}
Home | Imprint | This part of the site doesn't use cookies.