setInstalledAt example



    private function installNotSupportedPlugin(string $name): PluginEntity
    {
        /** @var EntityRepository $pluginRepository */
        $pluginRepository = $this->getContainer()->get('plugin.repository');
        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('name', $name));
        $result = $pluginRepository->search($criteria$this->context);
        $result = $result->getEntities()->first();
        $date = new \DateTime();
        $result->setInstalledAt($date);
        $pluginRepository->update([[
            'id' => $result->getId(),
            'installedAt' => $date->format(Defaults::STORAGE_DATE_TIME_FORMAT),
        ]]$this->context);

        return $result;
    }

    private function installPluginTest(Context $context): void
    {
        $pluginInstalled = $this->installAndActivatePlugin($context);
        
'autoload' => ['psr-4' => ['SwagTest\\' => 'src/']],
            'createdAt' => new \DateTimeImmutable('2019-01-01'),
            'managedByComposer' => false,
        ]);

        return $plugin;
    }

    protected function getInstalledInactivePlugin(): PluginEntity
    {
        $installed = $this->getNotInstalledPlugin();
        $installed->setInstalledAt(new \DateTimeImmutable());

        return $installed;
    }

    protected function getInstalledInactivePluginRebuildDisabled(): PluginEntity
    {
        $plugin = new PluginEntity();
        $plugin->assign([
            'id' => Uuid::randomHex(),
            'name' => 'SwagTestSkipRebuild',
            'baseClass' => SwagTestSkipRebuild::class,
            
$this->systemConfigService->savePluginConfiguration($pluginBaseClass, true);

            $pluginBaseClass->install($installContext);

            $this->customEntityLifecycleService->updatePlugin($plugin->getId()$plugin->getPath() ?? '');

            $this->runMigrations($installContext);

            $installDate = new \DateTime();
            $pluginData['installedAt'] = $installDate->format(Defaults::STORAGE_DATE_TIME_FORMAT);
            $plugin->setInstalledAt($installDate);

            $this->updatePluginData($pluginData$shopwareContext);

            $pluginBaseClass->postInstall($installContext);

            $this->eventDispatcher->dispatch(new PluginPostInstallEvent($plugin$installContext));
        } catch (\Throwable $e) {
            if ($didRunComposerRequire && $plugin->getComposerName()) {
                $this->executor->remove($plugin->getComposerName()$plugin->getName());
            }

            
$this->pluginMock->expects(static::once())->method('executeComposerCommands')->willReturn(true);

        static::expectException(PluginComposerJsonInvalidException::class);

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

    public function testInstallPluginAlreadyInstalled(): void
    {
        $pluginEntityMock = $this->getPluginEntityMock();
        $pluginEntityMock->setInstalledAt(new \DateTime());
        $context = Context::createDefaultContext();

        $this->kernelPluginCollectionMock->method('get')->with('MockPlugin')->willReturn($this->pluginMock);

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

        static::assertCount(0, $this->eventDispatcher->getEvents());
    }

    public function testUninstallPlugin(): void
    {
        
Home | Imprint | This part of the site doesn't use cookies.