function it_sets_not_started_payments_as_cancelled_while_creating_payment($paymentManager, $paymentFactory, OrderInterface $order, PaymentInterface $existingPayment, PaymentInterface $payment) { $existingPayment->getState()->willReturn('new'); $order->getPayments()->willReturn(array($existingPayment))->shouldBeCalled(); $existingPayment->setState('cancelled')->shouldBeCalled(); $paymentManager->flush()->shouldBeCalled(); $order->getCurrency()->willReturn('EUR')->shouldBeCalled(); $order->getTotal()->willReturn(100)->shouldBeCalled(); $paymentFactory->createNew()->willReturn($payment)->shouldBeCalled(); $payment->setCurrency('EUR')->shouldBeCalled(); $payment->setAmount(100)->shouldBeCalled(); $order->addPayment($payment)->shouldBeCalled(); $this->createPayment($order)->shouldReturn($payment); }
/** * @param PaymentInterface $payment */ private function cancelPaymentStateIfNotStarted(PaymentInterface $payment) { if (PaymentInterface::STATE_NEW === $payment->getState()) { $payment->setState(PaymentInterface::STATE_CANCELLED); } }