1010use Magento \Store \Model \ScopeInterface ;
1111
1212/**
13- * Class ValidationTest
13+ * Class ValidationTest validates the agreement based on the payment method
1414 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1515 */
1616class ValidationTest extends \PHPUnit \Framework \TestCase
@@ -60,12 +60,24 @@ class ValidationTest extends \PHPUnit\Framework\TestCase
6060 */
6161 private $ agreementsFilterMock ;
6262
63+ /**
64+ * @var \PHPUnit_Framework_MockObject_MockObject
65+ */
66+ private $ quoteMock ;
67+
68+ /**
69+ * @var \PHPUnit_Framework_MockObject_MockObject
70+ */
71+ private $ quoteRepositoryMock ;
72+
6373 protected function setUp ()
6474 {
6575 $ this ->agreementsValidatorMock = $ this ->createMock (\Magento \Checkout \Api \AgreementsValidatorInterface::class);
6676 $ this ->subjectMock = $ this ->createMock (\Magento \Checkout \Api \PaymentInformationManagementInterface::class);
6777 $ this ->paymentMock = $ this ->createMock (\Magento \Quote \Api \Data \PaymentInterface::class);
6878 $ this ->addressMock = $ this ->createMock (\Magento \Quote \Api \Data \AddressInterface::class);
79+ $ this ->quoteMock = $ this ->createPartialMock (\Magento \Quote \Model \Quote::class, ['getIsMultiShipping ' ]);
80+ $ this ->quoteRepositoryMock = $ this ->createMock (\Magento \Quote \Api \CartRepositoryInterface::class);
6981 $ this ->extensionAttributesMock = $ this ->createPartialMock (
7082 \Magento \Quote \Api \Data \PaymentExtension::class,
7183 ['getAgreementIds ' ]
@@ -82,7 +94,8 @@ protected function setUp()
8294 $ this ->agreementsValidatorMock ,
8395 $ this ->scopeConfigMock ,
8496 $ this ->checkoutAgreementsListMock ,
85- $ this ->agreementsFilterMock
97+ $ this ->agreementsFilterMock ,
98+ $ this ->quoteRepositoryMock
8699 );
87100 }
88101
@@ -96,6 +109,15 @@ public function testBeforeSavePaymentInformationAndPlaceOrder()
96109 ->with (AgreementsProvider::PATH_ENABLED , ScopeInterface::SCOPE_STORE )
97110 ->willReturn (true );
98111 $ searchCriteriaMock = $ this ->createMock (\Magento \Framework \Api \SearchCriteria::class);
112+ $ this ->quoteMock
113+ ->expects ($ this ->once ())
114+ ->method ('getIsMultiShipping ' )
115+ ->willReturn (false );
116+ $ this ->quoteRepositoryMock
117+ ->expects ($ this ->once ())
118+ ->method ('getActive ' )
119+ ->with ($ cartId )
120+ ->willReturn ($ this ->quoteMock );
99121 $ this ->agreementsFilterMock ->expects ($ this ->once ())
100122 ->method ('buildSearchCriteria ' )
101123 ->willReturn ($ searchCriteriaMock );
@@ -124,6 +146,15 @@ public function testBeforeSavePaymentInformationAndPlaceOrderIfAgreementsNotVali
124146 ->with (AgreementsProvider::PATH_ENABLED , ScopeInterface::SCOPE_STORE )
125147 ->willReturn (true );
126148 $ searchCriteriaMock = $ this ->createMock (\Magento \Framework \Api \SearchCriteria::class);
149+ $ this ->quoteMock
150+ ->expects ($ this ->once ())
151+ ->method ('getIsMultiShipping ' )
152+ ->willReturn (false );
153+ $ this ->quoteRepositoryMock
154+ ->expects ($ this ->once ())
155+ ->method ('getActive ' )
156+ ->with ($ cartId )
157+ ->willReturn ($ this ->quoteMock );
127158 $ this ->agreementsFilterMock ->expects ($ this ->once ())
128159 ->method ('buildSearchCriteria ' )
129160 ->willReturn ($ searchCriteriaMock );
@@ -152,6 +183,15 @@ public function testBeforeSavePaymentInformation()
152183 ->method ('isSetFlag ' )
153184 ->with (AgreementsProvider::PATH_ENABLED , ScopeInterface::SCOPE_STORE )
154185 ->willReturn (true );
186+ $ this ->quoteMock
187+ ->expects ($ this ->once ())
188+ ->method ('getIsMultiShipping ' )
189+ ->willReturn (false );
190+ $ this ->quoteRepositoryMock
191+ ->expects ($ this ->once ())
192+ ->method ('getActive ' )
193+ ->with ($ cartId )
194+ ->willReturn ($ this ->quoteMock );
155195 $ searchCriteriaMock = $ this ->createMock (\Magento \Framework \Api \SearchCriteria::class);
156196 $ this ->agreementsFilterMock ->expects ($ this ->once ())
157197 ->method ('buildSearchCriteria ' )
0 commit comments