Skip to content

Commit b12f812

Browse files
author
okarpenko
committed
MAGETWO-37571: [TechDebt] Covered php code after new checkout implementation by unit tests
1 parent 129569a commit b12f812

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,42 @@ public function testPlaceOrderIfCustomerIsGuest()
725725
$this->assertEquals($orderId, $service->placeOrder($cartId));
726726
}
727727

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+
728764
public function testPlaceOrder()
729765
{
730766
$cartId = 323;

0 commit comments

Comments
 (0)