@@ -118,13 +118,18 @@ class MultishippingTest extends \PHPUnit\Framework\TestCase
118118 */
119119 private $ quoteRepositoryMock ;
120120
121+ /**
122+ * @var PHPUnit_Framework_MockObject_MockObject
123+ */
124+ private $ scopeConfigMock ;
125+
121126 protected function setUp ()
122127 {
123128 $ this ->checkoutSessionMock = $ this ->createSimpleMock (Session::class);
124129 $ this ->customerSessionMock = $ this ->createSimpleMock (CustomerSession::class);
125130 $ orderFactoryMock = $ this ->createSimpleMock (OrderFactory::class);
126131 $ eventManagerMock = $ this ->createSimpleMock (ManagerInterface::class);
127- $ scopeConfigMock = $ this ->createSimpleMock (ScopeConfigInterface::class);
132+ $ this -> scopeConfigMock = $ this ->createSimpleMock (ScopeConfigInterface::class);
128133 $ sessionMock = $ this ->createSimpleMock (Generic::class);
129134 $ addressFactoryMock = $ this ->createSimpleMock (AddressFactory::class);
130135 $ toOrderMock = $ this ->createSimpleMock (ToOrder::class);
@@ -166,7 +171,7 @@ protected function setUp()
166171 $ orderFactoryMock ,
167172 $ this ->addressRepositoryMock ,
168173 $ eventManagerMock ,
169- $ scopeConfigMock ,
174+ $ this -> scopeConfigMock ,
170175 $ sessionMock ,
171176 $ addressFactoryMock ,
172177 $ toOrderMock ,
@@ -497,4 +502,37 @@ private function createSimpleMock($className)
497502 ->disableOriginalConstructor ()
498503 ->getMock ();
499504 }
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+ }
500538}
0 commit comments