PluginCollection example

/** @var EntityRepository $pluginRepository */
        $pluginRepository = $this->getContainer()->get('plugin.repository');
        $pluginRepository->update([
            [
                'id' => $firstPluginId,
                'upgradedAt' => $time,
            ],
        ], Context::createDefaultContext());

        $firstPlugin = $this->getContainer()->get('plugin.repository')->search($criteria, Context::createDefaultContext())->first();

        $extensions = $this->extensionLoader->loadFromPluginCollection(Context::createDefaultContext()new PluginCollection([$firstPlugin]));

        static::assertSame($time->getTimestamp()$extensions->first()->getUpdatedAt()->getTimestamp());
    }

    public function testItLoadsExtensionsFromAppsCollection(): void
    {
        $installedApp = $this->getInstalledApp();

        $extensions = $this->extensionLoader->loadFromAppCollection(
            Context::createDefaultContext(),
            new AppCollection([$installedApp])
        );
$commandTester->execute($options);

        return $commandTester;
    }

    /** * @param PluginEntity[] $entities */
    private function setupEntityCollection(array $entities): void
    {
        $result = $this->createMock(EntitySearchResult::class);
        $result->method('getEntities')->willReturn(new PluginCollection($entities));
        $this->pluginRepoMock->method('search')->willReturn($result);
    }
}
if ($choice === $choiceSelect) {
            $id = $io->askQuestion(
                new ChoiceQuestion(
                    sprintf(
                        'Which plugin do you want to %s?',
                        $lifecycleMethod
                    ),
                    $pluginCollection->map(fn (PluginEntity $plugin) => $plugin->getName())
                )
            );

            return new PluginCollection([$pluginCollection->get($id)]);
        }

        return $pluginCollection;
    }

    /** * @return array<string> */
    private function formatPluginList(PluginCollection $plugins): array
    {
        $pluginList = [];
        
$scheduledTasksRepo = $kernel->getContainer()->get('scheduled_task.repository');
        $result = $scheduledTasksRepo->search($criteria$context)->getEntities()->first();
        static::assertNull($result);
    }

    private function makePluginLifecycleService(): PluginLifecycleService
    {
        /** @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,
            
'path' => __DIR__,
            'composerPackage' => $completePackage,
            'managedByComposer' => true,
        ]);

        $pluginFinder
            ->method('findPlugins')
            ->willReturn([
                $pluginFromFileSystemStruct,
            ]);

        $pluginRepo = new StaticEntityRepository([new PluginCollection()]);
        $pluginService = new PluginService(
            __DIR__,
            __DIR__,
            $pluginRepo,
            $this->getLanguageRepository(),
            $pluginFinder,
            new VersionSanitizer()
        );

        $pluginService->refreshPlugins(Context::createDefaultContext()$this->createMock(IOInterface::class));

        
preg_quote('shopware/core', '#')
        ));
        $this->createValidator()->validateRequirements($plugin, Context::createDefaultContext(), 'test');
    }

    private function createValidator(): RequirementsValidator
    {
        $pluginRepo = $this->createMock(EntityRepository::class);
        $pluginRepo->method('search')->willReturn(new EntitySearchResult(
            'plugin',
            0,
            new PluginCollection(),
            null,
            new Criteria(),
            Context::createDefaultContext()
        ));

        return new RequirementsValidator(
            $pluginRepo,
            $this->projectDir
        );
    }

    

class PluginUpdateAllCommandTest extends TestCase
{
    public function testNoUpdates(): void
    {
        $pluginService = $this->createMock(PluginService::class);
        $pluginService->expects(static::once())->method('refreshPlugins');

        $pluginRepository = new StaticEntityRepository([new PluginCollection([
            $this->createPlugin('Test'),
            $this->createPlugin('Test2'),
        ])]);

        $pluginLifecycleService = $this->createMock(PluginLifecycleService::class);
        $pluginLifecycleService->expects(static::never())->method('updatePlugin');

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

        $tester = new CommandTester($command);
        
$frwClient = $this->createMock(FirstRunWizardClient::class);
        $frwClient->expects(static::once())
            ->method('getRecommendations')
            ->with('us', 'payment', $this->context)
            ->willReturn($recommendations);

        $frwService = $this->createFirstRunWizardService(
            frwClient: $frwClient,
        );

        $recommendations = $frwService->getRecommendations(
            new PluginCollection(),
            new AppCollection(),
            'us',
            'payment',
            $this->context
        );

        static::assertCount(3, $recommendations);
    }

    public function testFiltersOutRecommendedPluginsWithMissingName(): void
    {
        
private function createClientException(string $message): ClientException
    {
        return new ClientException($message$this->createMock(GuzzleRequest::class)new Response(400));
    }

    /** * @param array<string, mixed>[] $data */
    private function createPluginCollection(array $data): PluginCollection
    {
        $collection = new PluginCollection();
        $counter = \count($data);
        for ($i = 0; $i < $counter; ++$i) {
            if (!\array_key_exists('id', $data[$i])) {
                $data[$i]['id'] = Uuid::randomHex();
            }
            $collection->add((new PluginEntity())->assign($data[$i]));
        }

        return $collection;
    }

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