|
@@ 114-161 (lines=48) @@
|
| 111 |
|
$this->assertSame([], $orderLines); |
| 112 |
|
} |
| 113 |
|
|
| 114 |
|
public function testRefundAmountMatchesPaymentLineAmount() |
| 115 |
|
{ |
| 116 |
|
$amount = null; |
| 117 |
|
$orderLines = []; |
| 118 |
|
|
| 119 |
|
$altapayClient = $this->getAltapayClient(); |
| 120 |
|
$altapayClient |
| 121 |
|
->expects($this->any()) |
| 122 |
|
->method('refundCapturedReservation') |
| 123 |
|
->willReturnCallback(function ($val) use (&$amount, &$orderLines) { |
| 124 |
|
/** @var RefundCapturedReservationPayload $val */ |
| 125 |
|
$amount = $val->getAmount(); |
| 126 |
|
$orderLines = $val->getOrderLines(); |
| 127 |
|
|
| 128 |
|
$response = $this->getMockBuilder(RefundCapturedReservationResponse::class) |
| 129 |
|
->disableOriginalConstructor() |
| 130 |
|
->getMock() |
| 131 |
|
; |
| 132 |
|
|
| 133 |
|
return $response; |
| 134 |
|
}) |
| 135 |
|
; |
| 136 |
|
|
| 137 |
|
$payment = $this->getPayment(); |
| 138 |
|
$payment->setAltapayId('altapayid'); |
| 139 |
|
|
| 140 |
|
/** @var PaymentLine|\PHPUnit_Framework_MockObject_MockObject $paymentLine */ |
| 141 |
|
$paymentLine = $this->getMockForAbstractClass(PaymentLine::class); |
| 142 |
|
$paymentLine->setPrice(79.96) |
| 143 |
|
->setVat(25) |
| 144 |
|
->setQuantity(1) |
| 145 |
|
->setName('name') |
| 146 |
|
->setProductNumber('productnumber') |
| 147 |
|
; |
| 148 |
|
|
| 149 |
|
$paymentHandler = $this->getPaymentHandler($altapayClient); |
| 150 |
|
$paymentHandler->refund($payment, [$paymentLine], 99.95); |
| 151 |
|
|
| 152 |
|
$this->assertSame(99.95, $amount); |
| 153 |
|
|
| 154 |
|
/** @var OrderLine $orderLine */ |
| 155 |
|
$orderLine = $orderLines[0]; |
| 156 |
|
$this->assertSame(99.95, $orderLine->getUnitPrice()); |
| 157 |
|
$this->assertSame(25.0, $orderLine->getTaxPercent()); |
| 158 |
|
$this->assertSame(1.0, $orderLine->getQuantity()); |
| 159 |
|
$this->assertSame('name', $orderLine->getDescription()); |
| 160 |
|
$this->assertSame('productnumber', $orderLine->getItemId()); |
| 161 |
|
} |
| 162 |
|
|
| 163 |
|
public function testRefundAmountDoesNotMatchPaymentLineAmount() |
| 164 |
|
{ |
|
@@ 163-209 (lines=47) @@
|
| 160 |
|
$this->assertSame('productnumber', $orderLine->getItemId()); |
| 161 |
|
} |
| 162 |
|
|
| 163 |
|
public function testRefundAmountDoesNotMatchPaymentLineAmount() |
| 164 |
|
{ |
| 165 |
|
$amount = null; |
| 166 |
|
$orderLines = []; |
| 167 |
|
|
| 168 |
|
$altapayClient = $this->getAltapayClient(); |
| 169 |
|
$altapayClient |
| 170 |
|
->expects($this->any()) |
| 171 |
|
->method('refundCapturedReservation') |
| 172 |
|
->willReturnCallback(function ($val) use (&$amount, &$orderLines) { |
| 173 |
|
/** @var RefundCapturedReservationPayload $val */ |
| 174 |
|
$amount = $val->getAmount(); |
| 175 |
|
$orderLines = $val->getOrderLines(); |
| 176 |
|
|
| 177 |
|
$response = $this->getMockBuilder(RefundCapturedReservationResponse::class) |
| 178 |
|
->disableOriginalConstructor() |
| 179 |
|
->getMock() |
| 180 |
|
; |
| 181 |
|
|
| 182 |
|
return $response; |
| 183 |
|
}) |
| 184 |
|
; |
| 185 |
|
|
| 186 |
|
$payment = $this->getPayment(); |
| 187 |
|
$payment->setAltapayId('altapayid'); |
| 188 |
|
|
| 189 |
|
/** @var PaymentLine|\PHPUnit_Framework_MockObject_MockObject $paymentLine */ |
| 190 |
|
$paymentLine = $this->getMockForAbstractClass(PaymentLine::class); |
| 191 |
|
$paymentLine->setPrice(100) |
| 192 |
|
->setVat(25) |
| 193 |
|
->setQuantity(1) |
| 194 |
|
->setName('name') |
| 195 |
|
->setProductNumber('productnumber') |
| 196 |
|
; |
| 197 |
|
|
| 198 |
|
$paymentHandler = $this->getPaymentHandler($altapayClient); |
| 199 |
|
$paymentHandler->refund($payment, [$paymentLine], 80); |
| 200 |
|
|
| 201 |
|
$this->assertSame(80.0, $amount); |
| 202 |
|
|
| 203 |
|
/** @var OrderLine $orderLine */ |
| 204 |
|
$orderLine = $orderLines[0]; |
| 205 |
|
$this->assertSame(80.0, $orderLine->getUnitPrice()); |
| 206 |
|
$this->assertSame(1.0, $orderLine->getQuantity()); |
| 207 |
|
$this->assertSame('refund', $orderLine->getDescription()); |
| 208 |
|
$this->assertSame('refund', $orderLine->getItemId()); |
| 209 |
|
} |
| 210 |
|
|
| 211 |
|
/** |
| 212 |
|
* @return Payment|\PHPUnit_Framework_MockObject_MockObject |