Skip to content

Commit dd4eb14

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-71870' into MPI-PR-Regression2
2 parents 600a116 + 77c6b5e commit dd4eb14

File tree

2 files changed

+45
-3
lines changed
  • app/code/Magento/Sales/Model/AdminOrder
  • dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder

2 files changed

+45
-3
lines changed

app/code/Magento/Sales/Model/AdminOrder/Create.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,6 +1586,9 @@ public function applyCoupon($code)
15861586
public function setAccountData($accountData)
15871587
{
15881588
$customer = $this->getQuote()->getCustomer();
1589+
if (empty($accountData['email'])) {
1590+
$accountData['email'] = $customer->getEmail();
1591+
}
15891592
$form = $this->_createCustomerForm($customer);
15901593

15911594
// emulate request

dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,14 +430,19 @@ public function testCreateOrderNewCustomer()
430430
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
431431
* @magentoDbIsolation enabled
432432
* @magentoAppIsolation enabled
433+
* @dataProvider createOrderNewCustomerWithFailedFirstPlaceOrderActionDataProvider
434+
* @param string $customerEmailFirstAttempt
435+
* @param string $customerEmailSecondAttempt
433436
*/
434-
public function testCreateOrderNewCustomerWithFailedFirstPlaceOrderAction()
435-
{
437+
public function testCreateOrderNewCustomerWithFailedFirstPlaceOrderAction(
438+
$customerEmailFirstAttempt,
439+
$customerEmailSecondAttempt
440+
) {
436441
$productIdFromFixture = 1;
437442
$shippingMethod = 'freeshipping_freeshipping';
438443
$paymentMethod = 'checkmo';
439444
$shippingAddressAsBilling = 1;
440-
$customerEmail = '[email protected]';
445+
$customerEmail = $customerEmailFirstAttempt;
441446
$orderData = [
442447
'currency' => 'USD',
443448
'account' => ['group_id' => '1', 'email' => $customerEmail],
@@ -469,10 +474,44 @@ public function testCreateOrderNewCustomerWithFailedFirstPlaceOrderAction()
469474
Bootstrap::getObjectManager()->removeSharedInstance(OrderManagementInterface::class);
470475
}
471476

477+
$customerEmail = $customerEmailSecondAttempt ? :$this->_model->getQuote()->getCustomer()->getEmail();
478+
$orderData['account']['email'] = $customerEmailSecondAttempt;
479+
480+
$this->_preparePreconditionsForCreateOrder(
481+
$productIdFromFixture,
482+
$customerEmail,
483+
$shippingMethod,
484+
$shippingAddressAsBilling,
485+
$paymentData,
486+
$orderData,
487+
$paymentMethod
488+
);
489+
472490
$order = $this->_model->createOrder();
473491
$this->_verifyCreatedOrder($order, $shippingMethod);
474492
}
475493

494+
/**
495+
* Email before and after failed first place order action.
496+
*
497+
* @case #1 Is the same.
498+
* @case #2 Is empty.
499+
* @case #3 Filled after failed first place order action.
500+
* @case #4 Empty after failed first place order action.
501+
* @case #5 Changed after failed first place order action.
502+
* @return array
503+
*/
504+
public function createOrderNewCustomerWithFailedFirstPlaceOrderActionDataProvider()
505+
{
506+
return [
507+
508+
2 => ['', ''],
509+
3 => ['', '[email protected]'],
510+
4 => ['[email protected]', ''],
511+
512+
];
513+
}
514+
476515
/**
477516
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
478517
* @magentoDataFixture Magento/Customer/_files/customer.php

0 commit comments

Comments
 (0)