PluginLifecycleService example

$dbMigrations = $connection
            ->fetchAllAssociative(
                'SELECT * FROM `migration` WHERE `class` REGEXP :pattern ORDER BY `creation_timestamp`',
                ['pattern' => $migrationSource->getNamespacePattern()]
            );

        TestCase::assertCount($expectedCount$dbMigrations);
    }

    private function createPluginLifecycleService(): PluginLifecycleService
    {
        return new PluginLifecycleService(
            $this->pluginRepo,
            $this->container->get('event_dispatcher'),
            $this->container->get(KernelPluginCollection::class),
            $this->container->get('service_container'),
            $this->container->get(MigrationCollectionLoader::class),
            $this->container->get(AssetService::class),
            $this->container->get(CommandExecutor::class),
            $this->container->get(RequirementsValidator::class),
            $this->container->get('cache.messenger.restart_workers_signal'),
            Kernel::SHOPWARE_FALLBACK_VERSION,
            $this->container->get(SystemConfigService::class),
            
/** @var Kernel $kernel */
        $kernel = $this->kernel;
        $container = $kernel->getContainer();

        $emptyPluginCollection = new PluginCollection();
        $pluginRepoMock = $this->createMock(EntityRepository::class);

        $pluginRepoMock
            ->method('search')
            ->willReturn(new EntitySearchResult('plugin', 0, $emptyPluginCollection, null, new Criteria(), Context::createDefaultContext()));

        return new PluginLifecycleService(
            $pluginRepoMock,
            $container->get('event_dispatcher'),
            $kernel->getPluginLoader()->getPluginInstances(),
            $container,
            $this->createMock(MigrationCollectionLoader::class),
            $this->createMock(AssetService::class),
            $this->createMock(CommandExecutor::class),
            $this->createMock(RequirementsValidator::class),
            new MemoryCacheItemPool(),
            $container->getParameter('kernel.shopware_version'),
            $this->createMock(SystemConfigService::class),
            

        $this->updateDeactivatedPluginWithException($this->context);
    }

    public function testAssetIsCalledOnlyWhenStateIsNotSet(): void
    {
        $assetService = $this->createMock(AssetService::class);
        $assetService
            ->expects(static::once())
            ->method('copyAssetsFromBundle');

        $service = new PluginLifecycleService(
            $this->pluginRepo,
            $this->container->get('event_dispatcher'),
            $this->pluginCollection,
            $this->container->get('service_container'),
            $this->container->get(MigrationCollectionLoader::class),
            $assetService,
            $this->container->get(CommandExecutor::class),
            $this->container->get(RequirementsValidator::class),
            $this->container->get('cache.messenger.restart_workers_signal'),
            Kernel::SHOPWARE_FALLBACK_VERSION,
            $this->systemConfigService,
            
$this->migrationLoaderMock = $this->createMock(MigrationCollectionLoader::class);
        $this->requirementsValidatorMock = $this->createMock(RequirementsValidator::class);
        $this->cacheItemPoolInterfaceMock = $this->createMock(CacheItemPoolInterface::class);
        $this->pluginServiceMock = $this->createMock(PluginService::class);
        $this->commandExecutor = $this->createMock(CommandExecutor::class);

        $this->pluginMock = $this->createMock(Plugin::class);

        $this->pluginMock->method('getNamespace')->willReturn('MockPlugin');
        $this->pluginMock->method('getMigrationNamespace')->willReturn('migration');

        $this->pluginLifecycleService = new PluginLifecycleService(
            $this->pluginRepoMock,
            $this->eventDispatcher,
            $this->kernelPluginCollectionMock,
            $this->containerMock,
            $this->migrationLoaderMock,
            $this->createMock(AssetService::class),
            $this->commandExecutor,
            $this->requirementsValidatorMock,
            $this->cacheItemPoolInterfaceMock,
            Kernel::SHOPWARE_FALLBACK_VERSION,
            $this->createMock(SystemConfigService::class),
            
Home | Imprint | This part of the site doesn't use cookies.