Skip to content

Commit 3a317e2

Browse files
committed
MCP-792: Wrong error message is sent in email if order is rejected because of disabled product
1 parent 18601a0 commit 3a317e2

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,37 @@ public function testSavePaymentInformationAndPlaceOrderWithLocalizedException()
233233
$this->model->savePaymentInformationAndPlaceOrder($cartId, $email, $paymentMock, $billingAddressMock);
234234
}
235235

236+
public function testSavePaymentInformationAndPlaceOrderWithDisabledProduct()
237+
{
238+
$this->expectException('Magento\Framework\Exception\CouldNotSaveException');
239+
$this->expectExceptionMessage('Some of the products are disabled.');
240+
$cartId = 100;
241+
$email = '[email protected]';
242+
$paymentMock = $this->getMockForAbstractClass(PaymentInterface::class);
243+
$billingAddressMock = $this->getMockForAbstractClass(AddressInterface::class);
244+
245+
$quoteMock = $this->createMock(Quote::class);
246+
$quoteMock->method('getBillingAddress')->willReturn($billingAddressMock);
247+
$quoteMock->expects($this->any())->method('getItemsQty')->willReturn(0);
248+
$this->cartRepositoryMock->method('getActive')->with($cartId)->willReturn($quoteMock);
249+
250+
$quoteIdMask = $this->getMockBuilder(QuoteIdMask::class)
251+
->addMethods(['getQuoteId'])
252+
->onlyMethods(['load'])
253+
->disableOriginalConstructor()
254+
->getMock();
255+
$this->quoteIdMaskFactoryMock->method('create')->willReturn($quoteIdMask);
256+
$quoteIdMask->method('load')->with($cartId, 'masked_id')->willReturnSelf();
257+
$quoteIdMask->method('getQuoteId')->willReturn($cartId);
258+
259+
$billingAddressMock->expects($this->once())->method('setEmail')->with($email)->willReturnSelf();
260+
261+
$this->paymentMethodManagementMock->expects($this->never())->method('set')->with($cartId, $paymentMock);
262+
$phrase = new Phrase(__('Some of the products are disabled.'));
263+
$exception = new CouldNotSaveException($phrase);
264+
$this->model->savePaymentInformationAndPlaceOrder($cartId, $email, $paymentMock, $billingAddressMock);
265+
}
266+
236267
/**
237268
* @param int $cartId
238269
* @param MockObject $billingAddressMock

0 commit comments

Comments
 (0)