@@ -118,13 +118,18 @@ class MultishippingTest extends \PHPUnit\Framework\TestCase
118
118
*/
119
119
private $ quoteRepositoryMock ;
120
120
121
+ /**
122
+ * @var PHPUnit_Framework_MockObject_MockObject
123
+ */
124
+ private $ scopeConfigMock ;
125
+
121
126
protected function setUp ()
122
127
{
123
128
$ this ->checkoutSessionMock = $ this ->createSimpleMock (Session::class);
124
129
$ this ->customerSessionMock = $ this ->createSimpleMock (CustomerSession::class);
125
130
$ orderFactoryMock = $ this ->createSimpleMock (OrderFactory::class);
126
131
$ eventManagerMock = $ this ->createSimpleMock (ManagerInterface::class);
127
- $ scopeConfigMock = $ this ->createSimpleMock (ScopeConfigInterface::class);
132
+ $ this -> scopeConfigMock = $ this ->createSimpleMock (ScopeConfigInterface::class);
128
133
$ sessionMock = $ this ->createSimpleMock (Generic::class);
129
134
$ addressFactoryMock = $ this ->createSimpleMock (AddressFactory::class);
130
135
$ toOrderMock = $ this ->createSimpleMock (ToOrder::class);
@@ -166,7 +171,7 @@ protected function setUp()
166
171
$ orderFactoryMock ,
167
172
$ this ->addressRepositoryMock ,
168
173
$ eventManagerMock ,
169
- $ scopeConfigMock ,
174
+ $ this -> scopeConfigMock ,
170
175
$ sessionMock ,
171
176
$ addressFactoryMock ,
172
177
$ toOrderMock ,
@@ -497,4 +502,37 @@ private function createSimpleMock($className)
497
502
->disableOriginalConstructor ()
498
503
->getMock ();
499
504
}
505
+
506
+ public function testValidateMinimumAmountMultiAddressTrue ()
507
+ {
508
+ $ this ->scopeConfigMock ->expects ($ this ->exactly (2 ))->method ('isSetFlag ' )->withConsecutive (
509
+ ['sales/minimum_order/active ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ],
510
+ ['sales/minimum_order/multi_address ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ]
511
+ )->willReturnOnConsecutiveCalls (true , true );
512
+
513
+ $ this ->checkoutSessionMock ->expects ($ this ->atLeastOnce ())->method ('getQuote ' )->willReturn ($ this ->quoteMock );
514
+ $ this ->quoteMock ->expects ($ this ->once ())->method ('validateMinimumAmount ' )->willReturn (false );
515
+ $ this ->assertFalse ($ this ->model ->validateMinimumAmount ());
516
+ }
517
+
518
+ public function testValidateMinimumAmountMultiAddressFalse ()
519
+ {
520
+ $ addressMock = $ this ->createMock (\Magento \Quote \Model \Quote \Address::class);
521
+ $ this ->scopeConfigMock ->expects ($ this ->exactly (2 ))->method ('isSetFlag ' )->withConsecutive (
522
+ ['sales/minimum_order/active ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ],
523
+ ['sales/minimum_order/multi_address ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ]
524
+ )->willReturnOnConsecutiveCalls (true , false );
525
+
526
+ $ this ->scopeConfigMock ->expects ($ this ->exactly (2 ))->method ('getValue ' )->withConsecutive (
527
+ ['sales/minimum_order/amount ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ],
528
+ ['sales/minimum_order/tax_including ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ]
529
+ )->willReturnOnConsecutiveCalls (100 , false );
530
+
531
+ $ this ->checkoutSessionMock ->expects ($ this ->atLeastOnce ())->method ('getQuote ' )->willReturn ($ this ->quoteMock );
532
+ $ this ->quoteMock ->expects ($ this ->once ())->method ('getStoreId ' )->willReturn (1 );
533
+ $ this ->quoteMock ->expects ($ this ->once ())->method ('getAllAddresses ' )->willReturn ([$ addressMock ]);
534
+ $ addressMock ->expects ($ this ->once ())->method ('getBaseSubtotalWithDiscount ' )->willReturn (101 );
535
+
536
+ $ this ->assertTrue ($ this ->model ->validateMinimumAmount ());
537
+ }
500
538
}
0 commit comments