public function cancel()
 {
     $expiredUnpaidOrders = $this->orderRepository->findOrdersUnpaidSince(new \DateTime('-' . $this->expirationPeriod));
     foreach ($expiredUnpaidOrders as $expiredUnpaidOrder) {
         $this->cancelOrder($expiredUnpaidOrder);
     }
 }
Пример #2
0
 function it_cancels_unpaid_orders(Factory $stateMachineFactory, OrderInterface $firstOrder, OrderInterface $secondOrder, OrderRepositoryInterface $orderRepository, StateMachineInterface $firstOrderStateMachine, StateMachineInterface $secondOrderStateMachine)
 {
     $orderRepository->findOrdersUnpaidSince(Argument::type(\DateTime::class))->willReturn([$firstOrder, $secondOrder]);
     $stateMachineFactory->get($firstOrder, 'sylius_order')->willReturn($firstOrderStateMachine);
     $stateMachineFactory->get($secondOrder, 'sylius_order')->willReturn($secondOrderStateMachine);
     $firstOrderStateMachine->apply(OrderTransitions::TRANSITION_CANCEL)->shouldBeCalled();
     $secondOrderStateMachine->apply(OrderTransitions::TRANSITION_CANCEL)->shouldBeCalled();
     $this->cancel();
 }