|
@@ 83-131 (lines=49) @@
|
| 80 |
|
$this->assertSame([], $orderLines); |
| 81 |
|
} |
| 82 |
|
|
| 83 |
|
public function testRefundAmountMatchesPaymentLineAmount() |
| 84 |
|
{ |
| 85 |
|
$amount = null; |
| 86 |
|
$orderLines = []; |
| 87 |
|
|
| 88 |
|
$altapayClient = $this->getAltapayClient(); |
| 89 |
|
$altapayClient |
| 90 |
|
->expects($this->any()) |
| 91 |
|
->method('refundCapturedReservation') |
| 92 |
|
->willReturnCallback(function ($val) use (&$amount, &$orderLines) { |
| 93 |
|
/** @var RefundCapturedReservationPayload $val */ |
| 94 |
|
$amount = $val->getAmount(); |
| 95 |
|
$orderLines = $val->getOrderLines(); |
| 96 |
|
|
| 97 |
|
$response = $this->getMockBuilder(RefundCapturedReservationResponse::class) |
| 98 |
|
->disableOriginalConstructor() |
| 99 |
|
->getMock() |
| 100 |
|
; |
| 101 |
|
|
| 102 |
|
return $response; |
| 103 |
|
}) |
| 104 |
|
; |
| 105 |
|
|
| 106 |
|
$payment = $this->getPayment(); |
| 107 |
|
$payment->setAltapayId('altapayid'); |
| 108 |
|
|
| 109 |
|
$paymentLines = []; |
| 110 |
|
/** @var PaymentLine|\PHPUnit_Framework_MockObject_MockObject $paymentLine */ |
| 111 |
|
$paymentLine = $this->getMockForAbstractClass(PaymentLine::class); |
| 112 |
|
$paymentLine->setPrice(79.96) |
| 113 |
|
->setVat(25) |
| 114 |
|
->setQuantity(1) |
| 115 |
|
->setName('name') |
| 116 |
|
->setProductNumber('productnumber') |
| 117 |
|
; |
| 118 |
|
|
| 119 |
|
$paymentHandler = $this->getPaymentHandler($altapayClient); |
| 120 |
|
$paymentHandler->refund($payment, [$paymentLine], 99.95); |
| 121 |
|
|
| 122 |
|
$this->assertSame(99.95, $amount); |
| 123 |
|
|
| 124 |
|
/** @var OrderLine $orderLine */ |
| 125 |
|
$orderLine = $orderLines[0]; |
| 126 |
|
$this->assertSame(99.95, $orderLine->getUnitPrice()); |
| 127 |
|
$this->assertSame(25.0, $orderLine->getTaxPercent()); |
| 128 |
|
$this->assertSame(1.0, $orderLine->getQuantity()); |
| 129 |
|
$this->assertSame('name', $orderLine->getDescription()); |
| 130 |
|
$this->assertSame('productnumber', $orderLine->getItemId()); |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
public function testRefundAmountDoesNotMatchPaymentLineAmount() |
| 134 |
|
{ |
|
@@ 133-180 (lines=48) @@
|
| 130 |
|
$this->assertSame('productnumber', $orderLine->getItemId()); |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
public function testRefundAmountDoesNotMatchPaymentLineAmount() |
| 134 |
|
{ |
| 135 |
|
$amount = null; |
| 136 |
|
$orderLines = []; |
| 137 |
|
|
| 138 |
|
$altapayClient = $this->getAltapayClient(); |
| 139 |
|
$altapayClient |
| 140 |
|
->expects($this->any()) |
| 141 |
|
->method('refundCapturedReservation') |
| 142 |
|
->willReturnCallback(function ($val) use (&$amount, &$orderLines) { |
| 143 |
|
/** @var RefundCapturedReservationPayload $val */ |
| 144 |
|
$amount = $val->getAmount(); |
| 145 |
|
$orderLines = $val->getOrderLines(); |
| 146 |
|
|
| 147 |
|
$response = $this->getMockBuilder(RefundCapturedReservationResponse::class) |
| 148 |
|
->disableOriginalConstructor() |
| 149 |
|
->getMock() |
| 150 |
|
; |
| 151 |
|
|
| 152 |
|
return $response; |
| 153 |
|
}) |
| 154 |
|
; |
| 155 |
|
|
| 156 |
|
$payment = $this->getPayment(); |
| 157 |
|
$payment->setAltapayId('altapayid'); |
| 158 |
|
|
| 159 |
|
$paymentLines = []; |
| 160 |
|
/** @var PaymentLine|\PHPUnit_Framework_MockObject_MockObject $paymentLine */ |
| 161 |
|
$paymentLine = $this->getMockForAbstractClass(PaymentLine::class); |
| 162 |
|
$paymentLine->setPrice(100) |
| 163 |
|
->setVat(25) |
| 164 |
|
->setQuantity(1) |
| 165 |
|
->setName('name') |
| 166 |
|
->setProductNumber('productnumber') |
| 167 |
|
; |
| 168 |
|
|
| 169 |
|
$paymentHandler = $this->getPaymentHandler($altapayClient); |
| 170 |
|
$paymentHandler->refund($payment, [$paymentLine], 80); |
| 171 |
|
|
| 172 |
|
$this->assertSame(80.0, $amount); |
| 173 |
|
|
| 174 |
|
/** @var OrderLine $orderLine */ |
| 175 |
|
$orderLine = $orderLines[0]; |
| 176 |
|
$this->assertSame(80.0, $orderLine->getUnitPrice()); |
| 177 |
|
$this->assertSame(1.0, $orderLine->getQuantity()); |
| 178 |
|
$this->assertSame('refund', $orderLine->getDescription()); |
| 179 |
|
$this->assertSame('refund', $orderLine->getItemId()); |
| 180 |
|
} |
| 181 |
|
|
| 182 |
|
/** |
| 183 |
|
* @return Payment|\PHPUnit_Framework_MockObject_MockObject |