@@ -167,13 +167,18 @@ class MultishippingTest extends \PHPUnit\Framework\TestCase
167
167
*/
168
168
private $ sessionMock ;
169
169
170
+ /**
171
+ * @var PHPUnit_Framework_MockObject_MockObject
172
+ */
173
+ private $ scopeConfigMock ;
174
+
170
175
protected function setUp ()
171
176
{
172
177
$ this ->checkoutSessionMock = $ this ->createSimpleMock (Session::class);
173
178
$ this ->customerSessionMock = $ this ->createSimpleMock (CustomerSession::class);
174
179
$ this ->orderFactoryMock = $ this ->createSimpleMock (OrderFactory::class);
175
180
$ eventManagerMock = $ this ->createSimpleMock (ManagerInterface::class);
176
- $ scopeConfigMock = $ this ->createSimpleMock (ScopeConfigInterface::class);
181
+ $ this -> scopeConfigMock = $ this ->createSimpleMock (ScopeConfigInterface::class);
177
182
$ this ->sessionMock = $ this ->createSimpleMock (Generic::class);
178
183
$ addressFactoryMock = $ this ->createSimpleMock (AddressFactory::class);
179
184
$ this ->toOrderMock = $ this ->createSimpleMock (ToOrder::class);
@@ -224,7 +229,7 @@ protected function setUp()
224
229
$ this ->orderFactoryMock ,
225
230
$ this ->addressRepositoryMock ,
226
231
$ eventManagerMock ,
227
- $ scopeConfigMock ,
232
+ $ this -> scopeConfigMock ,
228
233
$ this ->sessionMock ,
229
234
$ addressFactoryMock ,
230
235
$ this ->toOrderMock ,
@@ -277,6 +282,10 @@ public function testSetShippingItemsInformation()
277
282
->willReturn (null );
278
283
279
284
$ this ->quoteMock ->expects ($ this ->atLeastOnce ())->method ('getAllItems ' )->willReturn ([]);
285
+ $ this ->quoteMock ->expects ($ this ->once ())
286
+ ->method ('__call ' )
287
+ ->with ('setTotalsCollectedFlag ' , [false ])
288
+ ->willReturnSelf ();
280
289
281
290
$ this ->filterBuilderMock ->expects ($ this ->atLeastOnce ())->method ('setField ' )->willReturnSelf ();
282
291
$ this ->filterBuilderMock ->expects ($ this ->atLeastOnce ())->method ('setValue ' )->willReturnSelf ();
@@ -416,6 +425,10 @@ public function testSetShippingMethods()
416
425
$ addressMock ->expects ($ this ->once ())->method ('getId ' )->willReturn ($ addressId );
417
426
$ this ->quoteMock ->expects ($ this ->once ())->method ('getAllShippingAddresses ' )->willReturn ([$ addressMock ]);
418
427
$ addressMock ->expects ($ this ->once ())->method ('setShippingMethod ' )->with ($ methodsArray [$ addressId ]);
428
+ $ this ->quoteMock ->expects ($ this ->once ())
429
+ ->method ('__call ' )
430
+ ->with ('setTotalsCollectedFlag ' , [false ])
431
+ ->willReturnSelf ();
419
432
420
433
$ this ->mockShippingAssignment ();
421
434
@@ -809,4 +822,37 @@ private function createSimpleMock($className)
809
822
->disableOriginalConstructor ()
810
823
->getMock ();
811
824
}
825
+
826
+ public function testValidateMinimumAmountMultiAddressTrue ()
827
+ {
828
+ $ this ->scopeConfigMock ->expects ($ this ->exactly (2 ))->method ('isSetFlag ' )->withConsecutive (
829
+ ['sales/minimum_order/active ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ],
830
+ ['sales/minimum_order/multi_address ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ]
831
+ )->willReturnOnConsecutiveCalls (true , true );
832
+
833
+ $ this ->checkoutSessionMock ->expects ($ this ->atLeastOnce ())->method ('getQuote ' )->willReturn ($ this ->quoteMock );
834
+ $ this ->quoteMock ->expects ($ this ->once ())->method ('validateMinimumAmount ' )->willReturn (false );
835
+ $ this ->assertFalse ($ this ->model ->validateMinimumAmount ());
836
+ }
837
+
838
+ public function testValidateMinimumAmountMultiAddressFalse ()
839
+ {
840
+ $ addressMock = $ this ->createMock (\Magento \Quote \Model \Quote \Address::class);
841
+ $ this ->scopeConfigMock ->expects ($ this ->exactly (2 ))->method ('isSetFlag ' )->withConsecutive (
842
+ ['sales/minimum_order/active ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ],
843
+ ['sales/minimum_order/multi_address ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ]
844
+ )->willReturnOnConsecutiveCalls (true , false );
845
+
846
+ $ this ->scopeConfigMock ->expects ($ this ->exactly (2 ))->method ('getValue ' )->withConsecutive (
847
+ ['sales/minimum_order/amount ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ],
848
+ ['sales/minimum_order/tax_including ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ]
849
+ )->willReturnOnConsecutiveCalls (100 , false );
850
+
851
+ $ this ->checkoutSessionMock ->expects ($ this ->atLeastOnce ())->method ('getQuote ' )->willReturn ($ this ->quoteMock );
852
+ $ this ->quoteMock ->expects ($ this ->once ())->method ('getStoreId ' )->willReturn (1 );
853
+ $ this ->quoteMock ->expects ($ this ->once ())->method ('getAllAddresses ' )->willReturn ([$ addressMock ]);
854
+ $ addressMock ->expects ($ this ->once ())->method ('getBaseSubtotalWithDiscount ' )->willReturn (101 );
855
+
856
+ $ this ->assertTrue ($ this ->model ->validateMinimumAmount ());
857
+ }
812
858
}
0 commit comments