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);
}
public function it_is_get_data_test(
ServiceConflictsFinder $serviceConflictsFinder,
CacheProviderInterface $cacheProvider
): void {
$serviceId = 1;
$serviceId2 = 2;
$serviceConflictsFinder->getData($serviceId)->willReturn([2, 3])->shouldBeCalledOnce();
$serviceConflictsFinder->getData($serviceId2)->willReturn([7, 8])->shouldBeCalledOnce();
$cacheProvider->load(
sprintf('service_conflict_data_%s', $serviceId),
CacheLifetime::HOUR,
Argument::that(
function ($serviceId) {
call_user_func($serviceId);
return [2, 3];
}
)
)->willReturn([2, 3])->shouldBeCalledOnce();
$cacheProvider->load(
sprintf('service_conflict_data_%s', $serviceId2),
CacheLifetime::HOUR,
Argument::that(
function ($serviceId2) {
call_user_func($serviceId2);
return [7, 8];
}
)
)->willReturn([7, 8])->shouldBeCalledOnce();
$this->getDataOfConflictsServices([1, 2])->shouldBe([1 => [2, 3], 2 => [7, 8]]);
}
$this->shouldThrow(InvalidArgumentException::class)->during('vote', [$token, new Order(), ['xxx', 'yyy']]);
class FastOrderReturnCreatorSpec extends ObjectBehavior
{
public function it_is_initializable(): void
{
$this->shouldHaveType(FastOrderReturnCreator::class);
$this->shouldBeAnInstanceOf(OrderEditFormInterface::class);
}
public function let(
FormFactoryInterface $formFactory,
RouterInterface $router
): void {
$this->beConstructedWith($formFactory, $router);
}
public function it_creates_form(
FormFactoryInterface $formFactory,
RouterInterface $router,
OrderInterface $order,
FormInterface $form
): void {
$orderId = 1;
$url = '/order/fast-order-return/1';
$order->getId()->willReturn($orderId)->shouldBeCalledOnce();
$router->generate('enp_enp0026_order_fast_return', ['orderId' => $orderId])->willReturn($url);
$formFactory->createNamed(
'order_return',
FastOrderReturnType::class,
null,
[
'action' => $url,
'method' => Request::METHOD_PUT,
]
)->willReturn($form);
$this->createOrderEditForm($order)->shouldBe($form);
}
public function it_should_return_true(Order $order, TranslatorInterface $translator): void
{
$flagsToBlock = ['xxxx', 'aaaa', 'bbbb'];
$order->hasFlagByCode('xxxx')->willReturn(false);
$order->hasFlagByCode('aaaa')->willReturn(false);
$order->hasFlagByCode('bbbb')->willReturn(false);
$translator->trans(
'enp.order.order_quick_return.order_source.error',
[
'%flagsToBlock%' => implode(',', $flagsToBlock),
],
'EnpOrderBundle'
)->willReturn('message');
$this->beConstructedWith($flagsToBlock, $translator);
$this->check($order)->shouldReturn(true);
$this->getErrorMessage()->shouldBe('message');
}