@@ -233,6 +233,37 @@ public function testSavePaymentInformationAndPlaceOrderWithLocalizedException()
233
233
$ this ->model ->savePaymentInformationAndPlaceOrder ($ cartId , $ email , $ paymentMock , $ billingAddressMock );
234
234
}
235
235
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
+
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
+
236
267
/**
237
268
* @param int $cartId
238
269
* @param MockObject $billingAddressMock
0 commit comments