getRequestCount example



    public function testPayUntracked(): void
    {
        $paymentMethodId = $this->getPaymentMethodId('sync');
        $orderId = $this->createOrder($paymentMethodId);
        $transactionId = $this->createTransaction($orderId$paymentMethodId);
        $salesChannelContext = $this->getSalesChannelContext($paymentMethodId);

        $this->paymentService->handlePaymentByOrder($orderIdnew RequestDataBag()$salesChannelContext);

        static::assertSame(0, $this->getRequestCount());
        $this->assertOrderTransactionState(OrderTransactionStates::STATE_OPEN, $transactionId);
    }

    public function testPayOtherState(): void
    {
        $paymentMethodId = $this->getPaymentMethodId('syncTracked');
        $orderId = $this->createOrder($paymentMethodId);
        $transactionId = $this->createTransaction($orderId$paymentMethodId);
        $salesChannelContext = $this->getSalesChannelContext($paymentMethodId);

        $response = (new SyncPayResponse())->assign([
            


    public function testValidateWithoutUrl(): void
    {
        $paymentMethodId = $this->getPaymentMethodId('sync');
        $cart = Generator::createCart();
        $customerId = $this->createCustomer();
        $salesChannelContext = $this->getSalesChannelContext($paymentMethodId$customerId);

        $this->preparedPaymentService->handlePreOrderPayment($cartnew RequestDataBag()$salesChannelContext);

        static::assertSame(0, $this->getRequestCount());
    }

    public function testValidateWithErrorMessage(): void
    {
        $paymentMethodId = $this->getPaymentMethodId('prepared');
        $cart = Generator::createCart();
        $customerId = $this->createCustomer();
        $salesChannelContext = $this->getSalesChannelContext($paymentMethodId$customerId);

        $response = (new ValidateResponse())->assign([
            'message' => self::ERROR_MESSAGE,
        ]);
static::assertNotEmpty($registrationRequest->getHeaderLine(AuthMiddleware::SHOPWARE_CONTEXT_LANGUAGE));

        $secret = $setup->getSecret();
        static::assertNotNull($secret);

        $this->assertRequestIsSigned($registrationRequest$secret);

        $app = $this->fetchApp($id);

        static::assertEquals(TestAppServer::APP_SECRET, $app->getAppSecret());

        static::assertEquals(2, $this->getRequestCount());

        $confirmationReq = $this->getPastRequest(1);
        static::assertEquals('POST', $confirmationReq->getMethod());

        $postBody = \json_decode($confirmationReq->getBody()->getContents(), true, 512, \JSON_THROW_ON_ERROR);
        static::assertEquals($secretAccessKey$postBody['secretKey']);

        $integration = $app->getIntegration();
        static::assertNotNull($integration);
        static::assertEquals($integration->getAccessKey()$postBody['apiKey']);

        
$httpClient2 = $this->httpClientThatHasTracedRequests([
            [
                'method' => 'GET',
                'url' => 'http://localhost:8057/404',
            ],
        ]);
        $httpClient3 = $this->httpClientThatHasTracedRequests([]);
        $sut = new HttpClientDataCollector();
        $sut->registerClient('http_client1', $httpClient1);
        $sut->registerClient('http_client2', $httpClient2);
        $sut->registerClient('http_client3', $httpClient3);
        $this->assertEquals(0, $sut->getRequestCount());
        $sut->lateCollect();
        $this->assertEquals(3, $sut->getRequestCount());
    }

    public function testItCollectsErrorCount()
    {
        $httpClient1 = $this->httpClientThatHasTracedRequests([
            [
                'method' => 'GET',
                'url' => 'http://localhost:8057/',
            ],
            [
Home | Imprint | This part of the site doesn't use cookies.