function it_must_dispatch_pre_and_post_payment_state_changed_if_state_changed($factory, SecuredNotifyRequest $request, OrderInterface $order, PaymentModelInterface $paymentModel, PaymentInterface $payment, ObjectManager $objectManager, StateMachineInterface $sm, Collection $payments) { $request->getModel()->willReturn($paymentModel); $order->getPayments()->willReturn($payments); $payments->last()->willReturn($payment); $paymentModel->getState()->willReturn(Payment::STATE_PENDING); $factory->get($paymentModel, PaymentTransitions::GRAPH)->willReturn($sm); $sm->getTransitionToState('cancelled')->willReturn(PaymentTransitions::SYLIUS_CANCEL); $sm->apply(PaymentTransitions::SYLIUS_CANCEL)->shouldBeCalled()->will(function ($args) use($paymentModel) { $paymentModel->getState()->willReturn(Payment::STATE_CANCELLED); }); $payment->execute(Argument::type('Payum\\Core\\Request\\SyncRequest'))->willReturn(null); $payment->execute(Argument::type('Sylius\\Bundle\\PayumBundle\\Payum\\Request\\StatusRequest'))->will(function ($args) { $args[0]->markCanceled(); }); $objectManager->flush()->shouldBeCalled(); $this->execute($request); }
/** * @test */ public function shouldAllowSetModelAndKeepTokenSame() { $token = new Token(); $request = new SecuredNotifyRequest($notification = array(), $token); //guard $this->assertSame($token, $request->getToken()); $this->assertSame($token, $request->getModel()); $newModel = new \stdClass(); $request->setModel($newModel); $this->assertSame($token, $request->getToken()); $this->assertSame($newModel, $request->getModel()); }