TaxProviderPayload example

public function testEncode(): void
    {
        $context = new Context(new SystemSource());
        $salesChannelContext = static::createMock(SalesChannelContext::class);
        $salesChannelContext
            ->method('getContext')
            ->willReturn($context);

        $cart = new Cart($this->ids->get('cart'));
        $source = new Source('https://shopware.com', $this->ids->get('shop-id'), '1.0.0');
        $payload = new TaxProviderPayload($cart$salesChannelContext);
        $payload->setSource($source);

        $definitionInstanceRegistry = static::createMock(DefinitionInstanceRegistry::class);
        $definitionInstanceRegistry
            ->method('getByEntityClass')
            ->willReturn(new TaxProviderDefinition());

        $entityEncoder = new JsonEntityEncoder(
            new Serializer([new StructNormalizer()][new JsonEncoder()])
        );

        
->with($urlstatic::isType('array'))
            ->willReturn($response);

        $taxProviderPayloadService = new TaxProviderPayloadService(
            $appPayloadServiceHelper,
            $client,
            'https://test-shop.com'
        );

        $cart = new Cart($this->ids->get('cart'));
        $salesChannelContext = static::createMock(SalesChannelContext::class);
        $payload = new TaxProviderPayload($cart$salesChannelContext);

        $app = static::createMock(AppEntity::class);
        $app
            ->method('getVersion')
            ->willReturn('6.5-dev');
        $app
            ->method('getAppSecret')
            ->willReturn('very-secret');

        $taxResponse = $taxProviderPayloadService->request(
            $url,
            
return null;
    }

    private function handleAppRequest(
        AppEntity $app,
        string $processUrl,
        Cart $cart,
        SalesChannelContext $context
    ): ?TaxProviderResult {
        return $this->payloadService->request(
            $processUrl,
            new TaxProviderPayload($cart$context),
            $app,
            $context->getContext()
        );
    }
}
Home | Imprint | This part of the site doesn't use cookies.