Skip to content

Commit cbe8e7d

Browse files
MAGETWO-99624: [Magento Cloud] Checkout not possible with zero sum checkout for virtual products
1 parent 78b5ad5 commit cbe8e7d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

app/code/Magento/Checkout/Test/Unit/Model/PaymentInformationManagementTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,31 @@ public function testSavePaymentInformationAndPlaceOrderWithLocolizedException()
163163
$this->model->savePaymentInformationAndPlaceOrder($cartId, $paymentMock, $billingAddressMock);
164164
}
165165

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+
166191
/**
167192
* @param int $cartId
168193
* @param \PHPUnit_Framework_MockObject_MockObject $billingAddressMock
@@ -182,6 +207,7 @@ private function getMockForAssignBillingAddress($cartId, $billingAddressMock)
182207
$quoteMock->method('getBillingAddress')->willReturn($quoteBillingAddress);
183208
$quoteMock->expects($this->once())->method('getShippingAddress')->willReturn($quoteShippingAddress);
184209
$quoteBillingAddress->expects($this->once())->method('getId')->willReturn($billingAddressId);
210+
$quoteBillingAddress->expects($this->once())->method('getId')->willReturn($billingAddressId);
185211
$quoteMock->expects($this->once())->method('removeAddress')->with($billingAddressId);
186212
$quoteMock->expects($this->once())->method('setBillingAddress')->with($billingAddressMock);
187213
$quoteMock->expects($this->once())->method('setDataChanges')->willReturnSelf();

0 commit comments

Comments
 (0)