diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml
index 7b81f12624864..ff61b3be08af1 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml
@@ -63,7 +63,7 @@
-
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Data/CustomerData.xml b/app/code/Magento/Customer/Test/Mftf/Data/CustomerData.xml
index ab42dfe85e4ff..f07eb2ecb97ce 100644
--- a/app/code/Magento/Customer/Test/Mftf/Data/CustomerData.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Data/CustomerData.xml
@@ -21,6 +21,7 @@
John
Doe
S
+ John Doe
pwdTest123!
Mr
Sr
diff --git a/app/code/Magento/Quote/Model/QuoteManagement.php b/app/code/Magento/Quote/Model/QuoteManagement.php
index 6ed8393f80658..8f216b64aa9b0 100644
--- a/app/code/Magento/Quote/Model/QuoteManagement.php
+++ b/app/code/Magento/Quote/Model/QuoteManagement.php
@@ -25,6 +25,7 @@
/**
* Class QuoteManagement
*
+ * @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.TooManyFields)
*/
@@ -356,6 +357,13 @@ public function placeOrder($cartId, PaymentInterface $paymentMethod = null)
if ($quote->getCheckoutMethod() === self::METHOD_GUEST) {
$quote->setCustomerId(null);
$quote->setCustomerEmail($quote->getBillingAddress()->getEmail());
+ if ($quote->getCustomerFirstname() === null && $quote->getCustomerLastname() === null) {
+ $quote->setCustomerFirstname($quote->getBillingAddress()->getFirstname());
+ $quote->setCustomerLastname($quote->getBillingAddress()->getLastname());
+ if ($quote->getBillingAddress()->getMiddlename() === null) {
+ $quote->setCustomerMiddlename($quote->getBillingAddress()->getMiddlename());
+ }
+ }
$quote->setCustomerIsGuest(true);
$quote->setCustomerGroupId(\Magento\Customer\Api\Data\GroupInterface::NOT_LOGGED_IN_ID);
}
diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
index 72e516e35cd6e..b61f95b4eee6c 100644
--- a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
+++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
@@ -645,7 +645,7 @@ public function testPlaceOrderIfCustomerIsGuest()
$addressMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Address::class, ['getEmail']);
$addressMock->expects($this->once())->method('getEmail')->willReturn($email);
- $this->quoteMock->expects($this->once())->method('getBillingAddress')->with()->willReturn($addressMock);
+ $this->quoteMock->expects($this->any())->method('getBillingAddress')->with()->willReturn($addressMock);
$this->quoteMock->expects($this->once())->method('setCustomerIsGuest')->with(true)->willReturnSelf();
$this->quoteMock->expects($this->once())
diff --git a/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php b/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php
index 72c5d7736a30d..15f555a67e722 100644
--- a/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php
+++ b/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php
@@ -98,6 +98,9 @@ public function testSetCustomerData(): void
$customer = $quote->getCustomer();
$this->assertEquals($expected, $this->convertToArray($customer));
$this->assertEquals('qa@example.com', $quote->getCustomerEmail());
+ $this->assertEquals('Joe', $quote->getCustomerFirstname());
+ $this->assertEquals('Dou', $quote->getCustomerLastname());
+ $this->assertEquals('Ivan', $quote->getCustomerMiddlename());
}
/**