function it_must_not_dispatch_pre_and_post_payment_state_changed_if_state_not_changed(Request $request, ProcessContextInterface $context, GatewayInterface $gateway, EventDispatcherInterface $eventDispatcher) { $context->getRequest()->willReturn($request); $order = new Order(); $paymentModel = new Payment(); $paymentModel->setState(Payment::STATE_COMPLETED); $paymentModel->setOrder($order); $order->addPayment($paymentModel); $gateway->execute(Argument::type('Sylius\\Bundle\\PayumBundle\\Request\\GetStatus'))->will(function ($args) use($order, $paymentModel) { $args[0]->markCaptured(); $args[0]->setModel($paymentModel); }); $eventDispatcher->dispatch(SyliusCheckoutEvents::PURCHASE_INITIALIZE, Argument::type('Symfony\\Component\\EventDispatcher\\GenericEvent'))->shouldBeCalled(); $eventDispatcher->dispatch(SyliusCheckoutEvents::PURCHASE_PRE_COMPLETE, Argument::type('Symfony\\Component\\EventDispatcher\\GenericEvent'))->shouldBeCalled(); $eventDispatcher->dispatch(SyliusCheckoutEvents::PURCHASE_COMPLETE, Argument::type('Sylius\\Bundle\\CoreBundle\\Event\\PurchaseCompleteEvent'))->shouldBeCalled(); $this->forwardAction($context)->shouldReturnAnInstanceOf('Sylius\\Bundle\\FlowBundle\\Process\\Step\\ActionResult'); }
function it_must_not_dispatch_pre_and_post_payment_state_changed_if_state_not_changed($factory, ProcessContextInterface $context, PaymentInterface $payment, EventDispatcherInterface $eventDispatcher, StateMachineInterface $sm) { $order = new Order(); $paymentModel = new Payment(); $paymentModel->setState(Payment::STATE_COMPLETED); $paymentModel->setOrder($order); $order->addPayment($paymentModel); $payment->execute(Argument::type('Sylius\\Bundle\\PayumBundle\\Payum\\Request\\StatusRequest'))->will(function ($args) use($order, $paymentModel) { $args[0]->markSuccess(); $args[0]->setModel($paymentModel); }); $factory->get($paymentModel, PaymentTransitions::GRAPH)->willReturn($sm); $sm->getTransitionToState('completed')->willReturn(null); $sm->apply(PaymentTransitions::SYLIUS_COMPLETE)->shouldNotBeCalled(); $eventDispatcher->dispatch(SyliusCheckoutEvents::PURCHASE_INITIALIZE, Argument::type('Symfony\\Component\\EventDispatcher\\GenericEvent'))->shouldBeCalled(); $eventDispatcher->dispatch(SyliusCheckoutEvents::PURCHASE_PRE_COMPLETE, Argument::type('Symfony\\Component\\EventDispatcher\\GenericEvent'))->shouldBeCalled(); $eventDispatcher->dispatch(SyliusCheckoutEvents::PURCHASE_COMPLETE, Argument::type('Sylius\\Bundle\\CoreBundle\\Event\\PurchaseCompleteEvent'))->shouldBeCalled(); $this->forwardAction($context)->shouldReturnAnInstanceOf('Sylius\\Bundle\\FlowBundle\\Process\\Step\\ActionResult'); }