/**
     * @test
     */
    public function shouldSetDetailsBackToOrderEvenIfExceptionThrown()
    {
        $expectedDetails = array('foo' => 'fooVal');

        $order = new Order();
        $order->setDetails($expectedDetails);

        $paymentMock = $this->createPaymentMock();
        $paymentMock
            ->expects($this->at(0))
            ->method('execute')
            ->with($this->isInstanceOf('Payum\Core\Request\GetHumanStatus'))
            ->will($this->returnCallback(function (GetHumanStatus $request) {
                $request->markPending();
            }))
        ;
        $paymentMock
            ->expects($this->at(1))
            ->method('execute')
            ->with($this->isInstanceOf('Payum\Core\Request\Capture'))
            ->will($this->returnCallback(function (Capture $request) {
                $details = $request->getModel();
                $details['bar'] = 'barVal';

                throw new \Exception();
            }))
        ;

        $action = new CaptureOrderAction();
        $action->setPayment($paymentMock);

        $this->setExpectedException('Exception');
        $action->execute($capture = new Capture($order));

        $this->assertSame($order, $capture->getFirstModel());
        $this->assertInstanceOf('ArrayAccess', $capture->getModel());
        $this->assertEquals(array('foo' => 'fooVal', 'bar' => 'barVal'), $order->getDetails());
    }
 /**
  * @test
  */
 public function shouldKeepOrderEvenIfExceptionThrown()
 {
     $details = array('foo' => 'fooVal');
     $order = new Order();
     $order->setDetails($details);
     $paymentMock = $this->createPaymentMock();
     $paymentMock->expects($this->at(0))->method('execute')->with($this->isInstanceOf('Payum\\Core\\Request\\GetHumanStatus'))->will($this->returnCallback(function (GetHumanStatus $request) {
         $request->markPending();
     }));
     $paymentMock->expects($this->at(1))->method('execute')->with($this->isInstanceOf('Payum\\Core\\Request\\Capture'))->will($this->throwException(new \Exception()));
     $action = new CaptureOrderAction();
     $action->setPayment($paymentMock);
     $this->setExpectedException('Exception');
     $action->execute($capture = new Capture($order));
     $this->assertSame($order, $capture->getModel());
 }