@@ -190,15 +190,23 @@ public function testPrepareCustomerQuote()
190
190
* @magentoDataFixture Magento/Paypal/_files/quote_express.php
191
191
* @magentoAppIsolation enabled
192
192
* @magentoDbIsolation enabled
193
+ * @param string $accountEmail
194
+ * @param string $expected
195
+ * @dataProvider placeGuestQuoteDataProvider
193
196
*/
194
- public function testPlaceGuestQuote ()
197
+ public function testPlaceGuestQuote ($ accountEmail , $ expected )
195
198
{
196
199
/** @var Quote $quote */
197
200
$ quote = $ this ->getFixtureQuote ();
198
201
$ quote ->setCheckoutMethod (Onepage::METHOD_GUEST ); // to dive into _prepareGuestQuote() on switch
199
202
$ quote ->getShippingAddress ()->setSameAsBilling (0 );
200
203
$ quote ->setReservedOrderId (null );
201
204
205
+ /* Simulate data returned from PayPal containing email as well
206
+ as email entered at checkout step */
207
+ $ quote->
getBillingAddress ()->
setEmail (
'[email protected] ' );
208
+ $ quote ->getBillingAddress ()->setOrigData ('email ' , $ accountEmail );
209
+
202
210
$ checkout = $ this ->getCheckout ($ quote );
203
211
$ checkout ->place ('token ' );
204
212
@@ -209,6 +217,7 @@ public function testPlaceGuestQuote()
209
217
$ quote ->getCustomerGroupId ()
210
218
);
211
219
220
+ $ this ->assertEquals ($ expected , $ quote ->getCustomerEmail ());
212
221
$ this ->assertNotEmpty ($ quote ->getBillingAddress ());
213
222
$ this ->assertNotEmpty ($ quote ->getShippingAddress ());
214
223
@@ -217,6 +226,17 @@ public function testPlaceGuestQuote()
217
226
$ this ->assertNotEmpty ($ order ->getShippingAddress ());
218
227
}
219
228
229
+ /**
230
+ * @return array
231
+ */
232
+ public function placeGuestQuoteDataProvider (): array
233
+ {
234
+ return [
235
+ 'case with account email absent ' => [
null ,
'[email protected] ' ],
236
+ 'case with account email present ' => [
'[email protected] ' ,
'[email protected] ' ],
237
+ ];
238
+ }
239
+
220
240
/**
221
241
* Place the order as guest when `Automatic Assignment to Customer Group` is enabled.
222
242
*
0 commit comments