Esempio n. 1
0
 /**
  * @test
  */
 public function shouldSetDetailsBackToPaymentEvenIfExceptionThrown()
 {
     $expectedDetails = array('foo' => 'fooVal');
     $payment = new Payment();
     $payment->setDetails($expectedDetails);
     $gatewayMock = $this->createGatewayMock();
     $gatewayMock->expects($this->at(0))->method('execute')->with($this->isInstanceOf(GetHumanStatus::class))->will($this->returnCallback(function (GetHumanStatus $request) {
         $request->markPending();
     }));
     $gatewayMock->expects($this->at(1))->method('execute')->with($this->isInstanceOf(Authorize::class))->will($this->returnCallback(function (Authorize $request) {
         $details = $request->getModel();
         $details['bar'] = 'barVal';
         throw new \Exception();
     }));
     $action = new AuthorizePaymentAction();
     $action->setGateway($gatewayMock);
     $this->setExpectedException('Exception');
     $action->execute($authorize = new Authorize($payment));
     $this->assertSame($payment, $authorize->getFirstModel());
     $this->assertInstanceOf('ArrayAccess', $authorize->getModel());
     $this->assertEquals(array('foo' => 'fooVal', 'bar' => 'barVal'), $payment->getDetails());
 }