@@ -103,10 +103,12 @@ public function testInitFromOrderAndCreateOrderFromQuoteWithAdditionalOptions()
103
103
104
104
$ customer = $ this ->objectManager ->create (Customer::class);
105
105
$ customer ->load (1 )->setDefaultBilling (null )->setDefaultShipping (null )->save ();
106
+ $ customerMock = $ this ->getMockedCustomer ();
106
107
107
108
$ rate = $ this ->objectManager ->create (Quote \Address \Rate::class);
108
109
$ rate ->setCode ('freeshipping_freeshipping ' );
109
110
111
+ $ this ->model ->getQuote ()->setCustomer ($ customerMock );
110
112
$ this ->model ->getQuote ()->getShippingAddress ()->addShippingRate ($ rate );
111
113
$ this ->model ->getQuote ()->getShippingAddress ()->setCountryId ('EE ' );
112
114
$ this ->model ->setShippingAsBilling (0 );
@@ -399,6 +401,11 @@ public function testCreateOrderNewCustomerDifferentAddresses()
399
401
$ paymentMethod
400
402
);
401
403
$ 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 ());
402
409
$ this ->verifyCreatedOrder ($ order , $ shippingMethod );
403
410
/** @var Customer $customer */
404
411
$ customer = $ this ->objectManager ->create (Customer::class);
@@ -569,6 +576,9 @@ public function testCreateOrderExistingCustomerDifferentAddresses()
569
576
$ paymentMethod ,
570
577
$ customerIdFromFixture
571
578
);
579
+ $ customerMock = $ this ->getMockedCustomer ();
580
+
581
+ $ this ->model ->getQuote ()->setCustomer ($ customerMock );
572
582
$ order = $ this ->model ->createOrder ();
573
583
$ this ->verifyCreatedOrder ($ order , $ shippingMethod );
574
584
$ this ->objectManager ->get (CustomerRegistry::class)
@@ -617,6 +627,9 @@ public function testCreateOrderExistingCustomer()
617
627
$ paymentMethod ,
618
628
$ customerIdFromFixture
619
629
);
630
+ $ customerMock = $ this ->getMockedCustomer ();
631
+
632
+ $ this ->model ->getQuote ()->setCustomer ($ customerMock );
620
633
$ order = $ this ->model ->createOrder ();
621
634
$ this ->verifyCreatedOrder ($ order , $ shippingMethod );
622
635
}
@@ -861,6 +874,7 @@ public function testSetBillingAddressStreetValidationErrors()
861
874
* They are set to message manager only during createOrder() call.
862
875
*/
863
876
$ this ->model ->setIsValidate (true )->setBillingAddress ($ invalidAddressData );
877
+ $ this ->model ->setIsValidate (true )->setShippingAddress ($ invalidAddressData );
864
878
try {
865
879
$ this ->model ->createOrder ();
866
880
$ this ->fail ('Validation errors are expected to lead to exception during createOrder() call. ' );
@@ -939,4 +953,33 @@ public function testCreateOrderExistingCustomerWhenDefaultAddressDiffersWithNew(
939
953
self ::assertEquals ('Validation is failed. ' , $ e ->getRawMessage ());
940
954
}
941
955
}
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
+ }
942
985
}
0 commit comments