getDefaultQueryParameters example

throw new \RuntimeException('First run wizard requires a logged in user');
        }

        $response = $this->client->request(
            Request::METHOD_POST,
            '/swplatform/firstrunwizard/login',
            [
                'json' => [
                    'shopwareId' => $shopwareId,
                    'password' => $password,
                ],
                'query' => $this->optionsProvider->getDefaultQueryParameters($context),
            ]
        );

        return json_decode($response->getBody()->getContents(), true, flags: \JSON_THROW_ON_ERROR);
    }

    /** * @return array{shopUserToken: array{token: string, expirationDate: string}, shopSecret: string} */
    public function upgradeAccessToken(Context $context): array
    {
        
->method('get')
            ->with('core.store.licenseHost')
            ->willReturn('domain.shopware.store');

        $provider = new StoreRequestOptionsProvider(
            $this->configureUserRepositorySearchMock(new UserCollection()static::never()),
            $systemConfigService,
            new InstanceService('sw-version', 'instance-id'),
            static::createMock(LocaleProvider::class)
        );

        $queries = $provider->getDefaultQueryParameters(Context::createDefaultContext());

        static::assertArrayHasKey('domain', $queries);
        static::assertEquals('domain.shopware.store', $queries['domain']);

        static::assertArrayHasKey('shopwareVersion', $queries);
        static::assertEquals('sw-version', $queries['shopwareVersion']);
    }

    public function testGetDefaultQueryParametersDelegatesToLocaleProvider(): void
    {
        $context = Context::createDefaultContext(new AdminApiSource('user-id'));

        

    protected function getHeaders(Context $context): array
    {
        return $this->optionsProvider->getAuthenticationHeader($context);
    }

    /** * @return array<string, mixed> */
    protected function getQueries(Context $context): array
    {
        return $this->optionsProvider->getDefaultQueryParameters($context);
    }

    protected function getShopwareVersion(): string
    {
        return $this->instanceService->getShopwareVersion();
    }

    /** * @param list<array<string, mixed>> $violationsData * * @return StoreLicenseViolationStruct[] */
->method('getDefaultQueryParameters')
            ->with($context)
            ->willReturn([
                'queries' => 'some-queries',
            ]);

        $frwRequestOptionsProvider = new FrwRequestOptionsProvider(
            $innerOptionsProvider,
            $userConfigRepositoryMock
        );

        $queries = $frwRequestOptionsProvider->getDefaultQueryParameters($context);

        static::assertEquals([
            'queries' => 'some-queries',
        ]$queries);
    }
}
public function testGetAuthenticationHeadersThrowsForIntegrations(): void
    {
        $context = new Context(new AdminApiSource(null, Uuid::randomHex()));

        static::expectException(InvalidContextSourceUserException::class);
        $this->storeRequestOptionsProvider->getAuthenticationHeader($context);
    }

    public function testGetDefaultQueriesReturnsLanguageFromContext(): void
    {
        $queries = $this->storeRequestOptionsProvider->getDefaultQueryParameters($this->storeContext);

        static::assertArrayHasKey('language', $queries);
        static::assertEquals(
            $this->getLanguageFromContext($this->storeContext),
            $queries['language']
        );
    }

    public function testGetDefaultQueriesReturnsShopwareVersion(): void
    {
        $queries = $this->storeRequestOptionsProvider->getDefaultQueryParameters($this->storeContext);

        
private readonly EntityRepository $userConfigRepository,
    ) {
    }

    public function getAuthenticationHeader(Context $context): array
    {
        return array_filter([self::SHOPWARE_TOKEN_HEADER => $this->getFrwUserToken($context)]);
    }

    public function getDefaultQueryParameters(Context $context): array
    {
        return $this->optionsProvider->getDefaultQueryParameters($context);
    }

    private function getFrwUserToken(Context $context): ?string
    {
        if (!$context->getSource() instanceof AdminApiSource) {
            throw new InvalidContextSourceException(AdminApiSource::class$context->getSource()::class);
        }

        /** @var AdminApiSource $contextSource */
        $contextSource = $context->getSource();

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