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'); }
function it_marks_order_as_new_if_no_payment_is_in_process(OrderInterface $order) { $payment1 = new Payment(); $payment1->setAmount(6000); $payment1->setState(PaymentInterface::STATE_NEW); $payment2 = new Payment(); $payment2->setAmount(4000); $payment2->setState(PaymentInterface::STATE_NEW); $payments = new ArrayCollection(array($payment1, $payment2)); $order->hasPayments()->willReturn(true); $order->getPayments()->willReturn($payments); $order->getTotal()->willReturn(10000); $order->setPaymentState(PaymentInterface::STATE_NEW)->shouldBeCalled(); $this->resolvePaymentState($order); }