UpdateSubscriber example

public function testCompilesAllThemes(): void
    {
        $themeService = $this->createMock(ThemeService::class);
        $themeLifecycleService = $this->createMock(ThemeLifecycleService::class);
        /** @var EntityRepository $salesChannelRepository */
        $salesChannelRepository = $this->getContainer()->get('sales_channel.repository');

        $context = Context::createDefaultContext();

        $themes = $this->setupThemes($context);

        $updateSubscriber = new UpdateSubscriber($themeService$themeLifecycleService$salesChannelRepository);
        $event = new UpdatePostFinishEvent(Context::createDefaultContext(), 'v6.2.0', 'v6.2.1');

        $themeLifecycleService->expects(static::once())->method('refreshThemes');
        $themeService->expects(static::atLeast(2))
            ->method('compileThemeById')
            ->willReturnCallback(function D$themeId$c) use (&$themes$context) {
                $this->assertEquals($context$c);
                $compiledThemes = [];
                if (isset($themes['otherTheme']) && $themes['otherTheme']['id'] === $themeId) {
                    $compiledThemes[] = $themes['otherTheme']['id'];
                    unset($themes['otherTheme']);
                }
$version = '6.0.1_test';

        $notificationServiceMock = $this->createMock(NotificationService::class);
        $notificationServiceMock->expects(static::once())->method('createNotification')->with(
            new TraversableContainsIdentical('Updated successfully to version ' . $version)
        );

        $eventMock = $this->createMock(UpdatePostFinishEvent::class);
        $eventMock->expects(static::any())->method('getContext')->willReturn($context);
        $eventMock->expects(static::any())->method('getNewVersion')->willReturn($version);

        $updateSubscriber = new UpdateSubscriber($notificationServiceMock);

        $updateSubscriber->updateFinishedDone($eventMock);
    }

    public function testUpdateSucessfullAdminScope(): void
    {
        $context = Context::createDefaultContext(new AdminApiSource('userId123', 'integrationId321'));
        $version = '6.0.1_test';

        $notificationServiceMock = $this->createMock(NotificationService::class);
        $notificationServiceMock->expects(static::once())->method('createNotification')->willReturnCallback(
            
Home | Imprint | This part of the site doesn't use cookies.