| @@ 17-48 (lines=32) @@ | ||
| 14 | ||
| 15 | final class PaymentHandlerTest extends TestCase |
|
| 16 | { |
|
| 17 | public function testRefund1() |
|
| 18 | { |
|
| 19 | $amount = null; |
|
| 20 | $orderLines = []; |
|
| 21 | ||
| 22 | $altapayClient = $this->getAltapayClient(); |
|
| 23 | $altapayClient |
|
| 24 | ->expects($this->any()) |
|
| 25 | ->method('refundCapturedReservation') |
|
| 26 | ->willReturnCallback(function ($val) use (&$amount, &$orderLines) { |
|
| 27 | /** @var RefundCapturedReservationPayload $val */ |
|
| 28 | $amount = $val->getAmount(); |
|
| 29 | $orderLines = $val->getOrderLines(); |
|
| 30 | ||
| 31 | $response = $this->getMockBuilder(RefundCapturedReservationResponse::class) |
|
| 32 | ->disableOriginalConstructor() |
|
| 33 | ->getMock() |
|
| 34 | ; |
|
| 35 | ||
| 36 | return $response; |
|
| 37 | }) |
|
| 38 | ; |
|
| 39 | ||
| 40 | $payment = $this->getPayment(); |
|
| 41 | $payment->setAltapayId('altapayid'); |
|
| 42 | ||
| 43 | $paymentHandler = $this->getPaymentHandler($altapayClient); |
|
| 44 | $paymentHandler->refund($payment); |
|
| 45 | ||
| 46 | $this->assertSame(null, $amount); |
|
| 47 | $this->assertSame([], $orderLines); |
|
| 48 | } |
|
| 49 | ||
| 50 | public function testRefund2() |
|
| 51 | { |
|
| @@ 50-81 (lines=32) @@ | ||
| 47 | $this->assertSame([], $orderLines); |
|
| 48 | } |
|
| 49 | ||
| 50 | public function testRefund2() |
|
| 51 | { |
|
| 52 | $amount = null; |
|
| 53 | $orderLines = []; |
|
| 54 | ||
| 55 | $altapayClient = $this->getAltapayClient(); |
|
| 56 | $altapayClient |
|
| 57 | ->expects($this->any()) |
|
| 58 | ->method('refundCapturedReservation') |
|
| 59 | ->willReturnCallback(function ($val) use (&$amount, &$orderLines) { |
|
| 60 | /** @var RefundCapturedReservationPayload $val */ |
|
| 61 | $amount = $val->getAmount(); |
|
| 62 | $orderLines = $val->getOrderLines(); |
|
| 63 | ||
| 64 | $response = $this->getMockBuilder(RefundCapturedReservationResponse::class) |
|
| 65 | ->disableOriginalConstructor() |
|
| 66 | ->getMock() |
|
| 67 | ; |
|
| 68 | ||
| 69 | return $response; |
|
| 70 | }) |
|
| 71 | ; |
|
| 72 | ||
| 73 | $payment = $this->getPayment(); |
|
| 74 | $payment->setAltapayId('altapayid'); |
|
| 75 | ||
| 76 | $paymentHandler = $this->getPaymentHandler($altapayClient); |
|
| 77 | $paymentHandler->refund($payment, null, 100.55); |
|
| 78 | ||
| 79 | $this->assertSame(100.55, $amount); |
|
| 80 | $this->assertSame([], $orderLines); |
|
| 81 | } |
|
| 82 | ||
| 83 | public function testRefundAmountMatchesPaymentLineAmount() |
|
| 84 | { |
|