10
10
use Magento \Store \Model \ScopeInterface ;
11
11
12
12
/**
13
- * Class ValidationTest
13
+ * Class ValidationTest validates the agreement based on the payment method
14
14
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
15
15
*/
16
16
class ValidationTest extends \PHPUnit \Framework \TestCase
@@ -60,12 +60,24 @@ class ValidationTest extends \PHPUnit\Framework\TestCase
60
60
*/
61
61
private $ agreementsFilterMock ;
62
62
63
+ /**
64
+ * @var \PHPUnit_Framework_MockObject_MockObject
65
+ */
66
+ private $ quoteMock ;
67
+
68
+ /**
69
+ * @var \PHPUnit_Framework_MockObject_MockObject
70
+ */
71
+ private $ quoteRepositoryMock ;
72
+
63
73
protected function setUp ()
64
74
{
65
75
$ this ->agreementsValidatorMock = $ this ->createMock (\Magento \Checkout \Api \AgreementsValidatorInterface::class);
66
76
$ this ->subjectMock = $ this ->createMock (\Magento \Checkout \Api \PaymentInformationManagementInterface::class);
67
77
$ this ->paymentMock = $ this ->createMock (\Magento \Quote \Api \Data \PaymentInterface::class);
68
78
$ 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);
69
81
$ this ->extensionAttributesMock = $ this ->createPartialMock (
70
82
\Magento \Quote \Api \Data \PaymentExtension::class,
71
83
['getAgreementIds ' ]
@@ -82,7 +94,8 @@ protected function setUp()
82
94
$ this ->agreementsValidatorMock ,
83
95
$ this ->scopeConfigMock ,
84
96
$ this ->checkoutAgreementsListMock ,
85
- $ this ->agreementsFilterMock
97
+ $ this ->agreementsFilterMock ,
98
+ $ this ->quoteRepositoryMock
86
99
);
87
100
}
88
101
@@ -96,6 +109,15 @@ public function testBeforeSavePaymentInformationAndPlaceOrder()
96
109
->with (AgreementsProvider::PATH_ENABLED , ScopeInterface::SCOPE_STORE )
97
110
->willReturn (true );
98
111
$ 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 );
99
121
$ this ->agreementsFilterMock ->expects ($ this ->once ())
100
122
->method ('buildSearchCriteria ' )
101
123
->willReturn ($ searchCriteriaMock );
@@ -124,6 +146,15 @@ public function testBeforeSavePaymentInformationAndPlaceOrderIfAgreementsNotVali
124
146
->with (AgreementsProvider::PATH_ENABLED , ScopeInterface::SCOPE_STORE )
125
147
->willReturn (true );
126
148
$ 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 );
127
158
$ this ->agreementsFilterMock ->expects ($ this ->once ())
128
159
->method ('buildSearchCriteria ' )
129
160
->willReturn ($ searchCriteriaMock );
@@ -152,6 +183,15 @@ public function testBeforeSavePaymentInformation()
152
183
->method ('isSetFlag ' )
153
184
->with (AgreementsProvider::PATH_ENABLED , ScopeInterface::SCOPE_STORE )
154
185
->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 );
155
195
$ searchCriteriaMock = $ this ->createMock (\Magento \Framework \Api \SearchCriteria::class);
156
196
$ this ->agreementsFilterMock ->expects ($ this ->once ())
157
197
->method ('buildSearchCriteria ' )
0 commit comments