@@ -163,6 +163,31 @@ public function testSavePaymentInformationAndPlaceOrderWithLocolizedException()
163
163
$ this ->model ->savePaymentInformationAndPlaceOrder ($ cartId , $ paymentMock , $ billingAddressMock );
164
164
}
165
165
166
+ /**
167
+ * Test for save payment and place order with new billing address
168
+ *
169
+ * @return void
170
+ */
171
+ public function testSavePaymentInformationAndPlaceOrderWithNewBillingAddress (): void
172
+ {
173
+ $ cartId = 100 ;
174
+ $ quoteBillingAddressId = 1 ;
175
+ $ customerId = 1 ;
176
+ $ quoteMock = $ this ->createMock (\Magento \Quote \Model \Quote::class);
177
+ $ quoteBillingAddress = $ this ->createMock (\Magento \Quote \Model \Quote \Address::class);
178
+ $ billingAddressMock = $ this ->createMock (\Magento \Quote \Api \Data \AddressInterface::class);
179
+ $ paymentMock = $ this ->createMock (\Magento \Quote \Api \Data \PaymentInterface::class);
180
+
181
+ $ quoteBillingAddress ->method ('getCustomerId ' )->willReturn ($ customerId );
182
+ $ quoteMock ->method ('getBillingAddress ' )->willReturn ($ quoteBillingAddress );
183
+ $ quoteBillingAddress ->method ('getId ' )->willReturn ($ quoteBillingAddressId );
184
+ $ this ->cartRepositoryMock ->method ('getActive ' )->with ($ cartId )->willReturn ($ quoteMock );
185
+
186
+ $ this ->paymentMethodManagementMock ->expects ($ this ->once ())->method ('set ' )->with ($ cartId , $ paymentMock );
187
+ $ billingAddressMock ->expects ($ this ->once ())->method ('setCustomerId ' )->with ($ customerId );
188
+ $ this ->assertTrue ($ this ->model ->savePaymentInformation ($ cartId , $ paymentMock , $ billingAddressMock ));
189
+ }
190
+
166
191
/**
167
192
* @param int $cartId
168
193
* @param \PHPUnit_Framework_MockObject_MockObject $billingAddressMock
@@ -182,6 +207,7 @@ private function getMockForAssignBillingAddress($cartId, $billingAddressMock)
182
207
$ quoteMock ->method ('getBillingAddress ' )->willReturn ($ quoteBillingAddress );
183
208
$ quoteMock ->expects ($ this ->once ())->method ('getShippingAddress ' )->willReturn ($ quoteShippingAddress );
184
209
$ quoteBillingAddress ->expects ($ this ->once ())->method ('getId ' )->willReturn ($ billingAddressId );
210
+ $ quoteBillingAddress ->expects ($ this ->once ())->method ('getId ' )->willReturn ($ billingAddressId );
185
211
$ quoteMock ->expects ($ this ->once ())->method ('removeAddress ' )->with ($ billingAddressId );
186
212
$ quoteMock ->expects ($ this ->once ())->method ('setBillingAddress ' )->with ($ billingAddressMock );
187
213
$ quoteMock ->expects ($ this ->once ())->method ('setDataChanges ' )->willReturnSelf ();
0 commit comments