|
1 | 1 | <?php
|
2 | 2 | /**
|
3 |
| - * Copyright © Magento, Inc. All rights reserved. |
4 |
| - * See COPYING.txt for license details. |
| 3 | + * Copyright 2015 Adobe |
| 4 | + * All Rights Reserved. |
5 | 5 | */
|
6 | 6 | declare(strict_types=1);
|
7 | 7 |
|
|
21 | 21 | use Magento\Sales\Model\OrderFactory;
|
22 | 22 | use PHPUnit\Framework\MockObject\MockObject;
|
23 | 23 | use PHPUnit\Framework\TestCase;
|
| 24 | +use Magento\Paypal\Model\Exception\UnknownIpnException; |
| 25 | +use Magento\Sales\Model\Order\Email\Sender\CreditmemoSender; |
| 26 | +use Magento\Sales\Model\Order\Email\Sender\OrderSender; |
| 27 | +use Magento\Sales\Model\OrderMutexInterface; |
| 28 | +use \Psr\Log\LoggerInterface; |
24 | 29 |
|
25 | 30 | class IpnTest extends TestCase
|
26 | 31 | {
|
@@ -115,7 +120,7 @@ protected function setUp(): void
|
115 | 120 | 'curlFactory' => $this->curlFactory,
|
116 | 121 | 'orderFactory' => $this->_orderMock,
|
117 | 122 | 'paypalInfo' => $this->_paypalInfo,
|
118 |
| - 'data' => ['payment_status' => 'Pending', 'pending_reason' => 'authorization'] |
| 123 | + 'data' => ['invoice' => '00000001', 'payment_status' => 'Pending', 'pending_reason' => 'authorization'] |
119 | 124 | ]
|
120 | 125 | );
|
121 | 126 | }
|
@@ -157,6 +162,35 @@ public function testPaymentReviewRegisterPaymentAuthorization()
|
157 | 162 | $this->_ipn->processIpnRequest();
|
158 | 163 | }
|
159 | 164 |
|
| 165 | + public function testProcessIpnRequestThrowsException() |
| 166 | + { |
| 167 | + $creditmemoSenderMock = $this->getMockBuilder(CreditmemoSender::class) |
| 168 | + ->disableOriginalConstructor() |
| 169 | + ->getMock(); |
| 170 | + $orderSenderMock = $this->getMockBuilder(OrderSender::class) |
| 171 | + ->disableOriginalConstructor() |
| 172 | + ->getMock(); |
| 173 | + $orderMutexMock = $this->getMockForAbstractClass(orderMutexInterface::class); |
| 174 | + $loggerMock = $this->getMockForAbstractClass(LoggerInterface::class); |
| 175 | + $this->_ipn = new Ipn( |
| 176 | + $this->configFactory, |
| 177 | + $loggerMock, |
| 178 | + $this->curlFactory, |
| 179 | + $this->_orderMock, |
| 180 | + $this->_paypalInfo, |
| 181 | + $orderSenderMock, |
| 182 | + $creditmemoSenderMock, |
| 183 | + $orderMutexMock, |
| 184 | + [ |
| 185 | + 'payment_status' => 'Pending', |
| 186 | + 'pending_reason' => 'fraud', |
| 187 | + 'fraud_management_pending_filters_1' => 'Maximum Transaction Amount', |
| 188 | + ] |
| 189 | + ); |
| 190 | + $this->expectException(UnknownIpnException::class); |
| 191 | + $this->_ipn->processIpnRequest(); |
| 192 | + } |
| 193 | + |
160 | 194 | public function testPaymentReviewRegisterPaymentFraud()
|
161 | 195 | {
|
162 | 196 | $paymentMock = $this->createPartialMock(
|
@@ -196,6 +230,7 @@ public function testPaymentReviewRegisterPaymentFraud()
|
196 | 230 | 'orderFactory' => $this->_orderMock,
|
197 | 231 | 'paypalInfo' => $this->_paypalInfo,
|
198 | 232 | 'data' => [
|
| 233 | + 'invoice' => '00000001', |
199 | 234 | 'payment_status' => 'Pending',
|
200 | 235 | 'pending_reason' => 'fraud',
|
201 | 236 | 'fraud_management_pending_filters_1' => 'Maximum Transaction Amount',
|
@@ -241,6 +276,7 @@ public function testRegisterPaymentDenial()
|
241 | 276 | 'orderFactory' => $this->_orderMock,
|
242 | 277 | 'paypalInfo' => $this->_paypalInfo,
|
243 | 278 | 'data' => [
|
| 279 | + 'invoice' => '00000001', |
244 | 280 | 'payment_status' => 'Denied',
|
245 | 281 | ]
|
246 | 282 | ]
|
|
0 commit comments