setUpgradeVersion example



        try {
            $pluginData['id'] = $plugin->getId();

            // Makes sure the version is updated in the db after a re-installation             $updateVersion = $plugin->getUpgradeVersion();
            if ($updateVersion !== null && $this->hasPluginUpdate($updateVersion$pluginVersion)) {
                $pluginData['version'] = $updateVersion;
                $plugin->setVersion($updateVersion);
                $pluginData['upgradeVersion'] = null;
                $plugin->setUpgradeVersion(null);
                $upgradeDate = new \DateTime();
                $pluginData['upgradedAt'] = $upgradeDate->format(Defaults::STORAGE_DATE_TIME_FORMAT);
                $plugin->setUpgradedAt($upgradeDate);
            }

            $this->eventDispatcher->dispatch(new PluginPreInstallEvent($plugin$installContext));

            $this->systemConfigService->savePluginConfiguration($pluginBaseClass, true);

            $pluginBaseClass->install($installContext);

            
static::expectException(\Exception::class);
        static::expectExceptionMessage('not working');

        $this->pluginLifecycleService->installPlugin($pluginEntityMock$context);
    }

    public function testInstallUpgradeVersion(): void
    {
        $pluginEntityMock = $this->getPluginEntityMock();
        $context = Context::createDefaultContext();

        $pluginEntityMock->setUpgradeVersion('9999999');

        $this->pluginLifecycleService->installPlugin($pluginEntityMock$context);

        static::assertNotNull($pluginEntityMock->getUpgradedAt());
    }

    public function testInstallPluginMajor(): void
    {
        $pluginEntityMock = $this->getPluginEntityMock();
        $context = Context::createDefaultContext();

        


        $updateMock = $this->createMock(UpdateContext::class);

        $pluginLifecycleService = $this->createMock(PluginLifecycleService::class);
        $pluginLifecycleService
            ->expects(static::once())
            ->method('updatePlugin')
            ->with($updateAblePlugin)
            ->willReturnCallback(function DPluginEntity $plugin, Context $context) use ($updateMock) {
                $plugin->setVersion((string) $plugin->getUpgradeVersion());
                $plugin->setUpgradeVersion(null);
                static::assertFalse($context->hasState(PluginLifecycleService::STATE_SKIP_ASSET_BUILDING));

                return $updateMock;
            });

        $command = new PluginUpdateAllCommand($pluginService$pluginRepository$pluginLifecycleService);
        $command->setHelperSet(new HelperSet());

        $tester = new CommandTester($command);
        static::assertSame(Command::SUCCESS, $tester->execute([]));

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