Skip to content

Commit 6ee38e7

Browse files
committed
Merge branch 'ACP2E-279' of https://github.com/magento-l3/magento2ce into L3-PR-2022-04-19
2 parents 88c4dfc + 621f207 commit 6ee38e7

File tree

5 files changed

+80
-8
lines changed

5 files changed

+80
-8
lines changed

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Create extends \Magento\Framework\DataObject implements \Magento\Checkout\
3333
/**
3434
* Xml default email domain path
3535
*/
36-
const XML_PATH_DEFAULT_EMAIL_DOMAIN = 'customer/create_account/email_domain';
36+
public const XML_PATH_DEFAULT_EMAIL_DOMAIN = 'customer/create_account/email_domain';
3737

3838
private const XML_PATH_EMAIL_REQUIRED_CREATE_ORDER = 'customer/create_account/email_required_create_order';
3939
/**
@@ -100,8 +100,6 @@ class Create extends \Magento\Framework\DataObject implements \Magento\Checkout\
100100
protected $_quote;
101101

102102
/**
103-
* Core registry
104-
*
105103
* @var \Magento\Framework\Registry
106104
*/
107105
protected $_coreRegistry = null;
@@ -1833,9 +1831,6 @@ protected function _validateCustomerData(\Magento\Customer\Api\Data\CustomerInte
18331831
*/
18341832
public function _prepareCustomer()
18351833
{
1836-
if ($this->getQuote()->getCustomerIsGuest()) {
1837-
return $this;
1838-
}
18391834
/** @var $store \Magento\Store\Model\Store */
18401835
$store = $this->getSession()->getStore();
18411836
$customer = $this->getQuote()->getCustomer();

dev/tests/integration/testsuite/Magento/Bundle/Model/Sales/AdminOrder/ReorderTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,23 @@ public function testReorderBundleProductWithCustomPrice(): void
6767
self::assertEquals(0, (int)$quoteItem->getCustomPrice());
6868
}
6969

70+
$customerMock = $this->getMockBuilder(\Magento\Customer\Model\Data\Customer::class)
71+
->disableOriginalConstructor()
72+
->setMethods(
73+
[
74+
'getGroupId',
75+
'getEmail',
76+
'_getExtensionAttributes'
77+
]
78+
)->getMock();
79+
$customerMock->method('getGroupId')
80+
->willReturn(1);
81+
$customerMock->method('getEmail')
82+
->willReturn('[email protected]');
83+
$customerMock->method('_getExtensionAttributes')
84+
->willReturn(null);
85+
$this->model->getQuote()->setCustomer($customerMock);
86+
7087
$shippingMethod = 'freeshipping_freeshipping';
7188
/** @var Rate $rate */
7289
$rate = $this->objectManager->create(Rate::class);

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/Sales/AdminOrder/ReorderTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,23 @@ public function testReorderConfigurableProductWithCustomPrice(): void
6767
self::assertEquals(0, (int)$quoteItem->getCustomPrice());
6868
}
6969

70+
$customerMock = $this->getMockBuilder(\Magento\Customer\Model\Data\Customer::class)
71+
->disableOriginalConstructor()
72+
->setMethods(
73+
[
74+
'getGroupId',
75+
'getEmail',
76+
'_getExtensionAttributes'
77+
]
78+
)->getMock();
79+
$customerMock->method('getGroupId')
80+
->willReturn(1);
81+
$customerMock->method('getEmail')
82+
->willReturn('[email protected]');
83+
$customerMock->method('_getExtensionAttributes')
84+
->willReturn(null);
85+
$this->model->getQuote()->setCustomer($customerMock);
86+
7087
$shippingMethod = 'freeshipping_freeshipping';
7188
/** @var Rate $rate */
7289
$rate = $this->objectManager->create(Rate::class);

dev/tests/integration/testsuite/Magento/Downloadable/_files/order_with_downloadable_product_with_additional_options.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
\Magento\Sales\Model\Order\Address::class,
99
[
1010
'data' => [
11-
'firstname' => 'guest',
12-
'lastname' => 'guest',
11+
'firstname' => 'guestfname',
12+
'lastname' => 'guestlname',
1313
'email' => '[email protected]',
1414
'street' => 'street',
1515
'city' => 'Los Angeles',

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,12 @@ public function testInitFromOrderAndCreateOrderFromQuoteWithAdditionalOptions()
103103

104104
$customer = $this->objectManager->create(Customer::class);
105105
$customer->load(1)->setDefaultBilling(null)->setDefaultShipping(null)->save();
106+
$customerMock = $this->getMockedCustomer();
106107

107108
$rate = $this->objectManager->create(Quote\Address\Rate::class);
108109
$rate->setCode('freeshipping_freeshipping');
109110

111+
$this->model->getQuote()->setCustomer($customerMock);
110112
$this->model->getQuote()->getShippingAddress()->addShippingRate($rate);
111113
$this->model->getQuote()->getShippingAddress()->setCountryId('EE');
112114
$this->model->setShippingAsBilling(0);
@@ -399,6 +401,11 @@ public function testCreateOrderNewCustomerDifferentAddresses()
399401
$paymentMethod
400402
);
401403
$order = $this->model->createOrder();
404+
$newBillAddress = $order->getBillingAddress();
405+
self::assertEquals($this->model->getQuote()->getCustomerFirstname(), $newBillAddress->getFirstname());
406+
self::assertEquals($this->model->getQuote()->getCustomerLastname(), $newBillAddress->getLastname());
407+
self::assertEquals($order->getCustomerFirstname(), $newBillAddress->getFirstname());
408+
self::assertEquals($order->getCustomerLastname(), $newBillAddress->getLastname());
402409
$this->verifyCreatedOrder($order, $shippingMethod);
403410
/** @var Customer $customer */
404411
$customer = $this->objectManager->create(Customer::class);
@@ -569,6 +576,9 @@ public function testCreateOrderExistingCustomerDifferentAddresses()
569576
$paymentMethod,
570577
$customerIdFromFixture
571578
);
579+
$customerMock = $this->getMockedCustomer();
580+
581+
$this->model->getQuote()->setCustomer($customerMock);
572582
$order = $this->model->createOrder();
573583
$this->verifyCreatedOrder($order, $shippingMethod);
574584
$this->objectManager->get(CustomerRegistry::class)
@@ -617,6 +627,9 @@ public function testCreateOrderExistingCustomer()
617627
$paymentMethod,
618628
$customerIdFromFixture
619629
);
630+
$customerMock = $this->getMockedCustomer();
631+
632+
$this->model->getQuote()->setCustomer($customerMock);
620633
$order = $this->model->createOrder();
621634
$this->verifyCreatedOrder($order, $shippingMethod);
622635
}
@@ -861,6 +874,7 @@ public function testSetBillingAddressStreetValidationErrors()
861874
* They are set to message manager only during createOrder() call.
862875
*/
863876
$this->model->setIsValidate(true)->setBillingAddress($invalidAddressData);
877+
$this->model->setIsValidate(true)->setShippingAddress($invalidAddressData);
864878
try {
865879
$this->model->createOrder();
866880
$this->fail('Validation errors are expected to lead to exception during createOrder() call.');
@@ -939,4 +953,33 @@ public function testCreateOrderExistingCustomerWhenDefaultAddressDiffersWithNew(
939953
self::assertEquals('Validation is failed.', $e->getRawMessage());
940954
}
941955
}
956+
957+
/**
958+
* Get customer mock object.
959+
*
960+
* @return \Magento\Customer\Model\Data\Customer
961+
*/
962+
private function getMockedCustomer()
963+
{
964+
$customerMock = $this->getMockBuilder(\Magento\Customer\Model\Data\Customer::class)
965+
->disableOriginalConstructor()
966+
->setMethods(
967+
[
968+
'getId',
969+
'getGroupId',
970+
'getEmail',
971+
'_getExtensionAttributes'
972+
]
973+
)->getMock();
974+
$customerMock->method('getId')
975+
->willReturn(1);
976+
$customerMock->method('getGroupId')
977+
->willReturn(1);
978+
$customerMock->method('getEmail')
979+
->willReturn('[email protected]');
980+
$customerMock->method('_getExtensionAttributes')
981+
->willReturn(null);
982+
983+
return $customerMock;
984+
}
942985
}

0 commit comments

Comments
 (0)