@@ -725,6 +725,42 @@ public function testPlaceOrderIfCustomerIsGuest()
725
725
$ this ->assertEquals ($ orderId , $ service ->placeOrder ($ cartId ));
726
726
}
727
727
728
+ /**
729
+ * @expectedException \Magento\Framework\Exception\CouldNotSaveException
730
+ */
731
+ public function testPlaceOrderIfAgreementsIsNotValid ()
732
+ {
733
+ $ this ->agreementsValidatorMock ->expects ($ this ->once ())->method ('isValid ' )->willReturn (false );
734
+
735
+ /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\QuoteManagement $service */
736
+ $ service = $ this ->getMock (
737
+ '\Magento\Quote\Model\QuoteManagement ' ,
738
+ ['submit ' ],
739
+ [
740
+ 'eventManager ' => $ this ->eventManager ,
741
+ 'quoteValidator ' => $ this ->quoteValidator ,
742
+ 'orderFactory ' => $ this ->orderFactory ,
743
+ 'orderManagement ' => $ this ->orderManagement ,
744
+ 'customerManagement ' => $ this ->customerManagement ,
745
+ 'quoteAddressToOrder ' => $ this ->quoteAddressToOrder ,
746
+ 'quoteAddressToOrderAddress ' => $ this ->quoteAddressToOrderAddress ,
747
+ 'quoteItemToOrderItem ' => $ this ->quoteItemToOrderItem ,
748
+ 'quotePaymentToOrderPayment ' => $ this ->quotePaymentToOrderPayment ,
749
+ 'userContext ' => $ this ->userContextMock ,
750
+ 'quoteRepository ' => $ this ->quoteRepositoryMock ,
751
+ 'customerRepository ' => $ this ->customerRepositoryMock ,
752
+ 'customerModelFactory ' => $ this ->customerFactoryMock ,
753
+ 'dataObjectHelper ' => $ this ->dataObjectHelperMock ,
754
+ 'storeManager ' => $ this ->storeManagerMock ,
755
+ 'checkoutSession ' => $ this ->checkoutSessionMock ,
756
+ 'customerSession ' => $ this ->customerSessionMock ,
757
+ 'accountManagement ' => $ this ->accountManagementMock ,
758
+ 'agreementsValidator ' => $ this ->agreementsValidatorMock ,
759
+ ]
760
+ );
761
+ $ service ->placeOrder (45 );
762
+ }
763
+
728
764
public function testPlaceOrder ()
729
765
{
730
766
$ cartId = 323 ;
0 commit comments