test commanda lub query cqrs

    private function clientLimitTest(
        PaymentLimiterDTO $paymentLimiterDTO,
        PaymentGroupInterface $paymentGroup,
        PaymentInterface $payment,
        AddressInterface $address,
        PaymentLimitDataValueObject $paymentLimitDataValueObject,
        OrderTotalAdapter $orderTotalAdapter,
        QueryBusInterface $queryBus,
        MoneyInterface $money,
        Cart $cart,
        int $orderTotalAmount,
        bool $expected
    ): void {
        //arrange
        $phone = '500500500';
        $address->getPhone()->willReturn($phone);
        $cart->getAccountAddress()->willReturn($address);
        $cart->getTotal()->willReturn($money);
        $money->getAmount()->willReturn($orderTotalAmount);
        $orderTotalAdapter->getTotalValue($orderTotalAmount)->willReturn($orderTotalAmount);
        $paymentLimiterDTO->getCart()->willReturn($cart);
        $payment = $payment->getWrappedObject();
        $paymentGroup->getFirstPaymentWithIntegration(PaymentIntegrationEnum::MOKKA)->willReturn($payment);
        $paymentLimiterDTO->getPaymentGroup()->willReturn($paymentGroup);
        $paymentLimitDataValueObject->clientIsActive()->willReturn(true);
        $paymentLimitDataValueObject->getClientLimitAmount()->willReturn('5666.00');
        $paymentLimitDataValueObject->getClientStatus()->willReturn(PaymentLimitApiCode::INACTIVE);
        $paymentLimitDataValueObject = $paymentLimitDataValueObject->getWrappedObject();
        $queryBus->handle(
            Argument::that(
                static function (PaymentLimitQueryMessage $message) use (
                    $phone,
                    $payment,
                    $paymentLimitDataValueObject
                ) {
                    $message->setPaymentLimitDataValueObject($paymentLimitDataValueObject);
                    return true;
                }
            )
        )->shouldBeCalledOnce();
        //act/assert
        $this->callOnWrappedObject('shouldExclude', [$paymentLimiterDTO])->shouldBeEqualTo($expected);
    }
Komentarze wyłączone