コード例 #1
0
 /**
  * @test
  */
 public function shouldKeepOrderEvenIfExceptionThrown()
 {
     $details = array('foo' => 'fooVal');
     $order = new Order();
     $order->setDetails($details);
     $paymentMock = $this->createPaymentMock();
     $paymentMock->expects($this->once())->method('execute')->with($this->isInstanceOf('Payum\\Core\\Request\\Notify'))->will($this->throwException(new \Exception()));
     $action = new NotifyOrderAction();
     $action->setPayment($paymentMock);
     $this->setExpectedException('Exception');
     $action->execute($capture = new Notify($order));
     $this->assertSame($order, $capture->getModel());
 }
コード例 #2
0
 function it_must_dispatch_pre_and_post_payment_state_changed_if_state_changed($factory, Notify $request, OrderInterface $order, PaymentModelInterface $paymentModel, PaymentInterface $payment, ObjectManager $objectManager, StateMachineInterface $sm, Collection $payments, TokenInterface $token)
 {
     $request->getModel()->willReturn($paymentModel);
     $request->getToken()->willReturn($token);
     $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\\Sync'))->willReturn(null);
     $payment->execute(Argument::type('Sylius\\Bundle\\PayumBundle\\Payum\\Request\\GetStatus'))->will(function ($args) {
         $args[0]->markCanceled();
     });
     $objectManager->flush()->shouldBeCalled();
     $this->execute($request);
 }
コード例 #3
0
 /**
  * @test
  */
 public function shouldSetOkIfVerifyRequestIsOk()
 {
     $gatewayMock = $this->createGatewayMock();
     $gatewayMock->expects($this->once())->method('execute')->with($this->isInstanceOf(GetHttpRequest::class))->will($this->returnCallback(function (GetHttpRequest $request) {
         $request->request = ['merchantReference' => 'SomeReference', 'authResult' => 'result'];
     }));
     $apiMock = $this->createApiMock();
     $apiMock->expects($this->once())->method('verifyNotification')->willReturn(true);
     $action = new NotifyAction();
     $action->setGateway($gatewayMock);
     $action->setApi($apiMock);
     $details = new \ArrayObject(['merchantReference' => 'SomeReference']);
     $action->execute($notify = new Notify($details));
     $model = $notify->getModel();
     $this->assertSame(200, $model['response_status']);
     $this->assertSame('result', $model['authResult']);
 }
コード例 #4
0
ファイル: NotifyTest.php プロジェクト: Studio-40/Payum
 /**
  * @test
  */
 public function shouldAllowGetModelSetInConstructor()
 {
     $expectedModel = new \stdClass();
     $request = new Notify(array(), $expectedModel);
     $this->assertSame($expectedModel, $request->getModel());
 }