diff --git a/.phpunit.result.cache b/.phpunit.result.cache new file mode 100644 index 00000000..2de2a6da --- /dev/null +++ b/.phpunit.result.cache @@ -0,0 +1 @@ +{"version":1,"defects":[],"times":[]} \ No newline at end of file diff --git a/spec/EventListener/OrderCreationListenerSpec.php b/spec/EventListener/OrderCreationListenerSpec.php index e222948d..c3c000b4 100644 --- a/spec/EventListener/OrderCreationListenerSpec.php +++ b/spec/EventListener/OrderCreationListenerSpec.php @@ -44,6 +44,7 @@ function it_completes_order_before_creation( $stateMachineFactory->get($order, 'sylius_order_checkout')->willReturn($stateMachine); $stateMachine->apply(OrderCheckoutTransitions::TRANSITION_ADDRESS)->shouldBeCalled(); + $stateMachine->can(OrderCheckoutTransitions::TRANSITION_SELECT_SHIPPING)->willReturn(true); $stateMachine->apply(OrderCheckoutTransitions::TRANSITION_SELECT_SHIPPING)->shouldBeCalled(); $stateMachine->can(OrderCheckoutTransitions::TRANSITION_SELECT_PAYMENT)->willReturn(true); $stateMachine->apply(OrderCheckoutTransitions::TRANSITION_SELECT_PAYMENT)->shouldBeCalled(); @@ -62,6 +63,7 @@ function it_completes_order_without_payment_before_creation( $stateMachineFactory->get($order, 'sylius_order_checkout')->willReturn($stateMachine); $stateMachine->apply(OrderCheckoutTransitions::TRANSITION_ADDRESS)->shouldBeCalled(); + $stateMachine->can(OrderCheckoutTransitions::TRANSITION_SELECT_SHIPPING)->willReturn(true); $stateMachine->apply(OrderCheckoutTransitions::TRANSITION_SELECT_SHIPPING)->shouldBeCalled(); $stateMachine->can(OrderCheckoutTransitions::TRANSITION_SELECT_PAYMENT)->willReturn(false); $stateMachine->apply(OrderCheckoutTransitions::TRANSITION_SELECT_PAYMENT)->shouldNotBeCalled(); @@ -70,18 +72,35 @@ function it_completes_order_without_payment_before_creation( $this->completeOrderBeforeCreation($event); } + function it_completes_order_without_shipping_before_creation( + FactoryInterface $stateMachineFactory, + GenericEvent $event, + StateMachineInterface $stateMachine, + OrderInterface $order + ) { + $event->getSubject()->willReturn($order); + + $stateMachineFactory->get($order, 'sylius_order_checkout')->willReturn($stateMachine); + $stateMachine->apply(OrderCheckoutTransitions::TRANSITION_ADDRESS)->shouldBeCalled(); + $stateMachine->can(OrderCheckoutTransitions::TRANSITION_SELECT_SHIPPING)->willReturn(false); + $stateMachine->apply(OrderCheckoutTransitions::TRANSITION_SELECT_SHIPPING)->shouldNotBeCalled(); + $stateMachine->can(OrderCheckoutTransitions::TRANSITION_SELECT_PAYMENT)->willReturn(true); + $stateMachine->apply(OrderCheckoutTransitions::TRANSITION_SELECT_PAYMENT)->shouldBeCalled(); + $stateMachine->apply(OrderCheckoutTransitions::TRANSITION_COMPLETE)->shouldBeCalled(); + + $this->completeOrderBeforeCreation($event); + } + function it_throws_exception_if_event_subject_is_not_order(GenericEvent $event) { $event->getSubject()->willReturn('badObject', 'badObject'); $this ->shouldThrow(\InvalidArgumentException::class) - ->during('processOrderBeforeCreation', [$event]) - ; + ->during('processOrderBeforeCreation', [$event]); $this ->shouldThrow(\InvalidArgumentException::class) - ->during('completeOrderBeforeCreation', [$event]) - ; + ->during('completeOrderBeforeCreation', [$event]); } }