8
8
9
9
namespace Magento \Multishipping \Test \Unit \Block \Checkout ;
10
10
11
+ use Magento \Framework \App \Config \ScopeConfigInterface ;
11
12
use Magento \Framework \Pricing \PriceCurrencyInterface ;
12
13
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
13
14
use Magento \Framework \UrlInterface ;
@@ -67,6 +68,11 @@ class OverviewTest extends TestCase
67
68
*/
68
69
private $ urlBuilderMock ;
69
70
71
+ /**
72
+ * @var MockObject
73
+ */
74
+ private $ scopeConfigMock ;
75
+
70
76
protected function setUp (): void
71
77
{
72
78
$ objectManager = new ObjectManager ($ this );
@@ -85,14 +91,16 @@ protected function setUp(): void
85
91
$ this ->createMock (Multishipping::class);
86
92
$ this ->quoteMock = $ this ->createMock (Quote::class);
87
93
$ this ->urlBuilderMock = $ this ->getMockForAbstractClass (UrlInterface::class);
94
+ $ this ->scopeConfigMock = $ this ->getMockForAbstractClass (ScopeConfigInterface::class);
88
95
$ this ->model = $ objectManager ->getObject (
89
96
Overview::class,
90
97
[
91
98
'priceCurrency ' => $ this ->priceCurrencyMock ,
92
99
'totalsCollector ' => $ this ->totalsCollectorMock ,
93
100
'totalsReader ' => $ this ->totalsReaderMock ,
94
101
'multishipping ' => $ this ->checkoutMock ,
95
- 'urlBuilder ' => $ this ->urlBuilderMock
102
+ 'urlBuilder ' => $ this ->urlBuilderMock ,
103
+ '_scopeConfig ' => $ this ->scopeConfigMock
96
104
]
97
105
);
98
106
}
@@ -187,4 +195,44 @@ public function testGetVirtualProductEditUrl()
187
195
$ this ->urlBuilderMock ->expects ($ this ->once ())->method ('getUrl ' )->with ('checkout/cart ' , [])->willReturn ($ url );
188
196
$ this ->assertEquals ($ url , $ this ->model ->getVirtualProductEditUrl ());
189
197
}
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
+ }
190
238
}
0 commit comments