@@ -191,6 +191,56 @@ public function testReturnFromPaypal()
191
191
$ this ->assertTrue ($ quote ->getTotalsCollectedFlag ());
192
192
}
193
193
194
+ /**
195
+ * Verify that guest customer quota has set type of checkout.
196
+ *
197
+ * @magentoDataFixture Magento/Paypal/_files/quote_payment_express.php
198
+ * @magentoAppIsolation enabled
199
+ * @magentoDbIsolation enabled
200
+ */
201
+ public function testGuestReturnFromPaypal ()
202
+ {
203
+ $ quote = $ this ->_getFixtureQuote ();
204
+ $ paypalConfigMock = $ this ->getMock ('Magento\Paypal\Model\Config ' , [], [], '' , false );
205
+ $ apiTypeFactory = $ this ->getMock ('Magento\Paypal\Model\Api\Type\Factory ' , [], [], '' , false );
206
+ $ paypalInfo = $ this ->getMock ('Magento\Paypal\Model\Info ' , [], [], '' , false );
207
+ $ checkoutModel = $ this ->_objectManager ->create (
208
+ 'Magento\Paypal\Model\Express\Checkout ' ,
209
+ [
210
+ 'params ' => ['quote ' => $ quote , 'config ' => $ paypalConfigMock ],
211
+ 'apiTypeFactory ' => $ apiTypeFactory ,
212
+ 'paypalInfo ' => $ paypalInfo
213
+ ]
214
+ );
215
+
216
+ $ api = $ this ->getMock (
217
+ 'Magento\Paypal\Model\Api\Nvp ' ,
218
+ ['call ' , 'getExportedShippingAddress ' , 'getExportedBillingAddress ' ],
219
+ [],
220
+ '' ,
221
+ false
222
+ );
223
+ $ api ->expects ($ this ->any ())->method ('call ' )->will ($ this ->returnValue ([]));
224
+ $ apiTypeFactory ->expects ($ this ->any ())->method ('create ' )->will ($ this ->returnValue ($ api ));
225
+
226
+ $ exportedBillingAddress = $ this ->_getExportedAddressFixture ($ quote ->getBillingAddress ()->getData ());
227
+ $ api ->expects ($ this ->any ())
228
+ ->method ('getExportedBillingAddress ' )
229
+ ->will ($ this ->returnValue ($ exportedBillingAddress ));
230
+
231
+ $ exportedShippingAddress = $ this ->_getExportedAddressFixture ($ quote ->getShippingAddress ()->getData ());
232
+ $ api ->expects ($ this ->any ())
233
+ ->method ('getExportedShippingAddress ' )
234
+ ->will ($ this ->returnValue ($ exportedShippingAddress ));
235
+
236
+ $ paypalInfo ->expects ($ this ->once ())->method ('importToPayment ' )->with ($ api , $ quote ->getPayment ());
237
+
238
+ $ quote ->getPayment ()->setAdditionalInformation (Checkout::PAYMENT_INFO_BUTTON , 1 );
239
+
240
+ $ checkoutModel ->returnFromPaypal ('token ' );
241
+ $ this ->assertEquals (Onepage::METHOD_GUEST , $ quote ->getCheckoutMethod ());
242
+ }
243
+
194
244
/**
195
245
* Prepare fixture for exported address
196
246
*
0 commit comments