88
99namespace Magento \Multishipping \Test \Unit \Block \Checkout ;
1010
11+ use Magento \Framework \App \Config \ScopeConfigInterface ;
1112use Magento \Framework \Pricing \PriceCurrencyInterface ;
1213use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
1314use Magento \Framework \UrlInterface ;
@@ -67,6 +68,11 @@ class OverviewTest extends TestCase
6768 */
6869 private $ urlBuilderMock ;
6970
71+ /**
72+ * @var MockObject
73+ */
74+ private $ scopeConfigMock ;
75+
7076 protected function setUp (): void
7177 {
7278 $ objectManager = new ObjectManager ($ this );
@@ -85,14 +91,16 @@ protected function setUp(): void
8591 $ this ->createMock (Multishipping::class);
8692 $ this ->quoteMock = $ this ->createMock (Quote::class);
8793 $ this ->urlBuilderMock = $ this ->getMockForAbstractClass (UrlInterface::class);
94+ $ this ->scopeConfigMock = $ this ->getMockForAbstractClass (ScopeConfigInterface::class);
8895 $ this ->model = $ objectManager ->getObject (
8996 Overview::class,
9097 [
9198 'priceCurrency ' => $ this ->priceCurrencyMock ,
9299 'totalsCollector ' => $ this ->totalsCollectorMock ,
93100 'totalsReader ' => $ this ->totalsReaderMock ,
94101 'multishipping ' => $ this ->checkoutMock ,
95- 'urlBuilder ' => $ this ->urlBuilderMock
102+ 'urlBuilder ' => $ this ->urlBuilderMock ,
103+ '_scopeConfig ' => $ this ->scopeConfigMock
96104 ]
97105 );
98106 }
@@ -187,4 +195,44 @@ public function testGetVirtualProductEditUrl()
187195 $ this ->urlBuilderMock ->expects ($ this ->once ())->method ('getUrl ' )->with ('checkout/cart ' , [])->willReturn ($ url );
188196 $ this ->assertEquals ($ url , $ this ->model ->getVirtualProductEditUrl ());
189197 }
198+
199+ /**
200+ * Test sort total information
201+ *
202+ * @return void
203+ */
204+ public function testSortCollectors (): void
205+ {
206+ $ sorts = [
207+ 'discount ' => 40 ,
208+ 'subtotal ' => 10 ,
209+ 'tax ' => 20 ,
210+ 'shipping ' => 30 ,
211+ ];
212+
213+ $ this ->scopeConfigMock ->method ('getValue ' )
214+ ->with ('sales/totals_sort ' , 'stores ' )
215+ ->willReturn ($ sorts );
216+
217+ $ totalsNotSorted = [
218+ 'subtotal ' => [],
219+ 'shipping ' => [],
220+ 'tax ' => [],
221+ ];
222+
223+ $ totalsExpected = [
224+ 'subtotal ' => [],
225+ 'tax ' => [],
226+ 'shipping ' => [],
227+ ];
228+
229+ $ method = new \ReflectionMethod ($ this ->model , 'sortTotals ' );
230+ $ method ->setAccessible (true );
231+ $ result = $ method ->invoke ($ this ->model , $ totalsNotSorted );
232+
233+ $ this ->assertEquals (
234+ $ totalsExpected ,
235+ $ result
236+ );
237+ }
190238}
0 commit comments