2828use Magento \Framework \Lock \LockManagerInterface ;
2929use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
3030use Magento \Quote \Api \CartRepositoryInterface ;
31+ use Magento \Quote \Model \CartMutexInterface ;
3132use Magento \Quote \Model \CustomerManagement ;
3233use Magento \Quote \Model \Quote ;
3334use Magento \Quote \Model \Quote \Address ;
@@ -203,8 +204,12 @@ class QuoteManagementTest extends TestCase
203204 private $ lockManagerMock ;
204205
205206 /**
206- * @inheritDoc
207- *
207+ * @var CartMutexInterface
208+ */
209+ private $ cartMutexMock ;
210+
211+ /**
212+ * @inheriDoc
208213 * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
209214 */
210215 protected function setUp (): void
@@ -255,6 +260,12 @@ protected function setUp(): void
255260 'setCustomerId ' ,
256261 'setRemoteIp ' ,
257262 'setXForwardedFor ' ,
263+ 'getCustomerFirstname ' ,
264+ 'getCustomerLastname ' ,
265+ 'getCustomerMiddlename ' ,
266+ 'setCustomerFirstname ' ,
267+ 'setCustomerLastname ' ,
268+ 'setCustomerMiddlename '
258269 ]
259270 )
260271 ->onlyMethods (
@@ -301,6 +312,9 @@ protected function setUp(): void
301312 $ this ->lockManagerMock = $ this ->getMockBuilder (LockManagerInterface::class)
302313 ->getMockForAbstractClass ();
303314
315+ $ this ->cartMutexMock = $ this ->getMockBuilder (CartMutexInterface::class)
316+ ->getMockForAbstractClass ();
317+
304318 $ this ->model = $ objectManager ->getObject (
305319 QuoteManagement::class,
306320 [
@@ -838,6 +852,7 @@ public function testSubmit(): void
838852 /**
839853 * @dataProvider guestPlaceOrderDataProvider
840854 * @return void
855+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
841856 */
842857 public function testPlaceOrderIfCustomerIsGuest (?string $ settledEmail , int $ countSetAddress ): void
843858 {
@@ -846,6 +861,9 @@ public function testPlaceOrderIfCustomerIsGuest(?string $settledEmail, int $coun
846861 $ orderIncrementId = 100003332 ;
847862 $ orderStatus = 'status1 ' ;
848863 $ email = 'email@mail.com ' ;
864+ $ firstName = 'TestFirst ' ;
865+ $ middleName = 'TestMiddle ' ;
866+ $ lastName = 'TestLast ' ;
849867
850868 $ this ->quoteRepositoryMock ->expects ($ this ->once ())
851869 ->method ('getActive ' )
@@ -870,12 +888,44 @@ public function testPlaceOrderIfCustomerIsGuest(?string $settledEmail, int $coun
870888 ->with ($ email )
871889 ->willReturnSelf ();
872890
873- $ addressMock = $ this ->createPartialMock (Address::class, ['getEmail ' ]);
891+ $ addressMock = $ this ->createPartialMock (
892+ Address::class,
893+ [
894+ 'getEmail ' ,
895+ 'getFirstname ' ,
896+ 'getLastname ' ,
897+ 'getMiddlename '
898+ ]
899+ );
874900 $ addressMock ->expects ($ this ->exactly ($ countSetAddress ))->method ('getEmail ' )->willReturn ($ email );
875901 $ this ->quoteMock ->expects ($ this ->any ())->method ('getBillingAddress ' )->with ()->willReturn ($ addressMock );
876902
877903 $ this ->quoteMock ->expects ($ this ->once ())->method ('setCustomerIsGuest ' )->with (true )->willReturnSelf ();
878904 $ this ->quoteMock ->expects ($ this ->once ())->method ('getCustomerId ' )->willReturn (null );
905+ $ this ->quoteMock ->expects ($ this ->once ())
906+ ->method ('getCustomerFirstname ' )
907+ ->willReturn (null );
908+ $ this ->quoteMock ->expects ($ this ->once ())
909+ ->method ('getCustomerLastname ' )
910+ ->willReturn (null );
911+ $ addressMock ->expects ($ this ->once ())
912+ ->method ('getFirstname ' )
913+ ->willReturn ($ firstName );
914+ $ addressMock ->expects ($ this ->once ())
915+ ->method ('getLastname ' )
916+ ->willReturn ($ lastName );
917+ $ this ->quoteMock ->expects ($ this ->once ())
918+ ->method ('setCustomerFirstname ' )
919+ ->willReturn ($ firstName );
920+ $ this ->quoteMock ->expects ($ this ->once ())
921+ ->method ('setCustomerLastname ' )
922+ ->willReturn ($ lastName );
923+ $ addressMock ->expects ($ this ->exactly (2 ))
924+ ->method ('getMiddlename ' )
925+ ->willReturn ($ middleName );
926+ $ this ->quoteMock ->expects ($ this ->once ())
927+ ->method ('setCustomerLastname ' )
928+ ->willReturn ($ middleName );
879929 $ this ->quoteMock ->expects ($ this ->once ())
880930 ->method ('setCustomerGroupId ' )
881931 ->with (GroupInterface::NOT_LOGGED_IN_ID );
@@ -908,7 +958,8 @@ public function testPlaceOrderIfCustomerIsGuest(?string $settledEmail, int $coun
908958 'quoteIdMaskFactory ' => $ this ->quoteIdMaskFactoryMock ,
909959 'addressRepository ' => $ this ->addressRepositoryMock ,
910960 'request ' => $ this ->requestMock ,
911- 'remoteAddress ' => $ this ->remoteAddressMock
961+ 'remoteAddress ' => $ this ->remoteAddressMock ,
962+ 'cartMutex ' => $ this ->cartMutexMock
912963 ]
913964 )
914965 ->getMock ();
@@ -990,7 +1041,8 @@ public function testPlaceOrder(): void
9901041 'quoteIdMaskFactory ' => $ this ->quoteIdMaskFactoryMock ,
9911042 'addressRepository ' => $ this ->addressRepositoryMock ,
9921043 'request ' => $ this ->requestMock ,
993- 'remoteAddress ' => $ this ->remoteAddressMock
1044+ 'remoteAddress ' => $ this ->remoteAddressMock ,
1045+ 'cartMutex ' => $ this ->cartMutexMock
9941046 ]
9951047 )
9961048 ->getMock ();
0 commit comments