@@ -80,6 +80,46 @@ public function testProcessIpnRequestFullRefund()
80
80
$ this ->assertEmpty ($ order ->getTotalOfflineRefunded ());
81
81
}
82
82
83
+ /**
84
+ * Refund full order amount by Paypal Express IPN message service with concurrent requests.
85
+ *
86
+ * @magentoDataFixture Magento/Paypal/_files/order_express_with_invoice_and_shipping.php
87
+ * @magentoConfigFixture current_store payment/paypal_express/active 1
88
+ * @magentoConfigFixture current_store paypal/general/merchant_country US
89
+ */
90
+ public function testProcessIpnRequestFullRefundConcurrent ()
91
+ {
92
+ $ ipnData = require __DIR__ . '/../_files/ipn_refund.php ' ;
93
+ $ ipnFactory = $ this ->_objectManager ->create (IpnFactory::class);
94
+ $ ipnModel = $ ipnFactory ->create (
95
+ [
96
+ 'data ' => $ ipnData ,
97
+ 'curlFactory ' => $ this ->_createMockedHttpAdapter ()
98
+ ]
99
+ );
100
+
101
+ $ ipnModel ->processIpnRequest ();
102
+ $ ipnModel ->processIpnRequest ();
103
+
104
+ $ order = $ this ->_objectManager ->create (Order::class);
105
+ $ order ->loadByIncrementId ('100000001 ' );
106
+
107
+ $ creditmemoItems = $ order ->getCreditmemosCollection ()->getItems ();
108
+ $ creditmemo = current ($ creditmemoItems );
109
+
110
+ $ this ->assertEquals (Order::STATE_CLOSED , $ order ->getState ()) ;
111
+ $ this ->assertCount (1 , $ creditmemoItems );
112
+ $ this ->assertEquals (Creditmemo::STATE_REFUNDED , $ creditmemo ->getState ());
113
+ $ this ->assertEquals (10 , $ order ->getSubtotalRefunded ());
114
+ $ this ->assertEquals (10 , $ order ->getBaseSubtotalRefunded ());
115
+ $ this ->assertEquals (20 , $ order ->getShippingRefunded ());
116
+ $ this ->assertEquals (20 , $ order ->getBaseShippingRefunded ());
117
+ $ this ->assertEquals (30 , $ order ->getTotalRefunded ());
118
+ $ this ->assertEquals (30 , $ order ->getBaseTotalRefunded ());
119
+ $ this ->assertEquals (30 , $ order ->getTotalOnlineRefunded ());
120
+ $ this ->assertEmpty ($ order ->getTotalOfflineRefunded ());
121
+ }
122
+
83
123
/**
84
124
* Partial refund of order amount by Paypal Express IPN message service.
85
125
*
@@ -253,11 +293,11 @@ protected function _createMockedHttpAdapter()
253
293
$ factory = $ this ->createPartialMock (\Magento \Framework \HTTP \Adapter \CurlFactory::class, ['create ' ]);
254
294
$ adapter = $ this ->createPartialMock (\Magento \Framework \HTTP \Adapter \Curl::class, ['read ' , 'write ' ]);
255
295
256
- $ adapter ->expects ($ this ->once ())->method ('read ' )->with ()->willReturn ("\nVERIFIED " );
296
+ $ adapter ->expects ($ this ->any ())->method ('read ' )->with ()->willReturn ("\nVERIFIED " );
257
297
258
- $ adapter ->expects ($ this ->once ())->method ('write ' );
298
+ $ adapter ->expects ($ this ->any ())->method ('write ' );
259
299
260
- $ factory ->expects ($ this ->once ())->method ('create ' )->with ()->willReturn ($ adapter );
300
+ $ factory ->expects ($ this ->any ())->method ('create ' )->with ()->willReturn ($ adapter );
261
301
return $ factory ;
262
302
}
263
303
0 commit comments