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