getRecommendations example

'query' => [
                        'market' => 'us-west',
                        'category' => 'payment',
                    ],
                ],
            ],
            $recommendations
        );

        static::assertEquals(
            $recommendations,
            $frwClient->getRecommendations('us-west', 'payment', $this->context)
        );
    }

    public function testGetLanguagePlugins(): void
    {
        $languagePlugins = [
            [
                'id' => 123456,
                'name' => 'SwagLanguagePack',
            ],
        ];

        
->method('getRecommendations')
            ->willReturn(new PluginRecommendationCollection([
                (new StorePluginStruct())->assign(['name' => $plugin1Name]),
            ]));

        $frwController = new FirstRunWizardController(
            $this->firstRunWizardService,
            $pluginRepository,
            $appRepository,
        );

        $response = $frwController->getRecommendations(new SymfonyRequest()$context);
        $responseData = $this->decodeJsonResponse($response);

        static::assertArrayHasKey('items', $responseData);
        static::assertArrayHasKey('total', $responseData);
    }

    public function testTryingToGetRecommendationsFails(): void
    {
        $context = $this->createContext();

        $pluginRepository = new StaticEntityRepository([
            
return $regions;
    }

    public function getRecommendations(
        PluginCollection $pluginCollection,
        AppCollection $appCollection,
        ?string $region,
        ?string $category,
        Context $context
    ): PluginRecommendationCollection {
        $recommendations = $this->frwClient->getRecommendations($region$category$context);

        return new PluginRecommendationCollection(
            $this->mapExtensionData($recommendations$pluginCollection$appCollection)
        );
    }

    public function getLicenseDomains(Context $context): LicenseDomainCollection
    {
        $licenseDomains = $this->frwClient->getLicenseDomains($context);

        $currentLicenseDomain = $this->configService->getString(StoreService::CONFIG_KEY_STORE_LICENSE_DOMAIN);
        
    public function getRecommendations(Request $request, Context $context): JsonResponse
    {
        $region = $request->query->has('region') ? (string) $request->query->get('region') : null;
        $category = $request->query->has('category') ? (string) $request->query->get('category') : null;

        /** @var PluginCollection $plugins */
        $plugins = $this->pluginRepo->search(new Criteria()$context)->getEntities();
        /** @var AppCollection $apps */
        $apps = $this->appRepo->search(new Criteria()$context)->getEntities();

        try {
            $recommendations = $this->frwService->getRecommendations($plugins$apps$region$category$context);
        } catch (ClientException $exception) {
            throw new StoreApiException($exception);
        }

        return new JsonResponse([
            'items' => $recommendations,
            'total' => \count($recommendations),
        ]);
    }

    #[Route(path: '/api/_action/store/frw/login', name: 'api.custom.store.frw.login', methods: ['POST'])]
$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
    {
Home | Imprint | This part of the site doesn't use cookies.