Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
VoidHandlerTest.php
Go to the documentation of this file.
1 <?php
7 
12 
13 class VoidHandlerTest extends \PHPUnit\Framework\TestCase
14 {
15  public function testHandle()
16  {
17  $paymentDO = $this->createMock(PaymentDataObjectInterface::class);
18  $paymentInfo = $this->getMockBuilder(Payment::class)
19  ->disableOriginalConstructor()
20  ->getMock();
21  $handlingSubject = [
22  'payment' => $paymentDO
23  ];
24 
25  $transaction = \Braintree\Transaction::factory(['id' => 1]);
26  $response = [
27  'object' => new \Braintree\Result\Successful($transaction, 'transaction')
28  ];
29 
30  $subjectReader = $this->getMockBuilder(SubjectReader::class)
31  ->disableOriginalConstructor()
32  ->getMock();
33 
34  $subjectReader->expects(static::once())
35  ->method('readPayment')
36  ->with($handlingSubject)
37  ->willReturn($paymentDO);
38  $paymentDO->expects(static::atLeastOnce())
39  ->method('getPayment')
40  ->willReturn($paymentInfo);
41  $subjectReader->expects(static::once())
42  ->method('readTransaction')
43  ->with($response)
44  ->willReturn($transaction);
45 
46  $paymentInfo->expects(static::never())
47  ->method('setTransactionId');
48 
49  $paymentInfo->expects(static::once())
50  ->method('setIsTransactionClosed')
51  ->with(true);
52  $paymentInfo->expects(static::once())
53  ->method('setShouldCloseParentTransaction')
54  ->with(true);
55 
56  $handler = new VoidHandler($subjectReader);
57  $handler->handle($handlingSubject, $response);
58  }
59 }
$transaction
$response
Definition: 404.php:11
$paymentInfo
catch(\Exception $e) $handler
Definition: index.php:30