@@ -252,30 +252,77 @@ public function testValidateMinimumAmountVirtual(): void
252
252
}
253
253
254
254
/**
255
- * @return void
255
+ * Provide data for test different cases
256
+ *
257
+ * @param void
258
+ * @return array
256
259
*/
257
- public function testValidateMinimumAmount (): void
260
+ public function getDataProvider (): array
258
261
{
259
- $ storeId = 1 ;
260
- $ scopeConfigValues = [
261
- ['sales/minimum_order/active ' , ScopeInterface::SCOPE_STORE , $ storeId , true ],
262
- ['sales/minimum_order/amount ' , ScopeInterface::SCOPE_STORE , $ storeId , 20 ],
263
- ['sales/minimum_order/include_discount_amount ' , ScopeInterface::SCOPE_STORE , $ storeId , true ],
264
- ['sales/minimum_order/tax_including ' , ScopeInterface::SCOPE_STORE , $ storeId , true ]
262
+ return [
263
+ 'Non-virtual Quote ' => [
264
+ 'scopeConfigValues ' => [
265
+ ['sales/minimum_order/active ' , ScopeInterface::SCOPE_STORE , 1 , true ],
266
+ ['sales/minimum_order/amount ' , ScopeInterface::SCOPE_STORE , 1 , 20 ],
267
+ ['sales/minimum_order/include_discount_amount ' , ScopeInterface::SCOPE_STORE , 1 , true ],
268
+ ['sales/minimum_order/tax_including ' , ScopeInterface::SCOPE_STORE , 1 , true ]
269
+ ],
270
+ 'address ' => [
271
+ 'setAddressType ' => 'billing '
272
+ ],
273
+ 'quote ' => [
274
+ 'getStoreId ' => 1 ,
275
+ 'getIsVirtual ' => false
276
+ ],
277
+ 'result ' => true
278
+ ],
279
+ 'With Shipping Discount ' => [
280
+ 'scopeConfigValues ' => [
281
+ ['sales/minimum_order/active ' , ScopeInterface::SCOPE_STORE , 1 , true ],
282
+ ['sales/minimum_order/amount ' , ScopeInterface::SCOPE_STORE , 1 , 2 ],
283
+ ['sales/minimum_order/include_discount_amount ' , ScopeInterface::SCOPE_STORE , 1 , true ],
284
+ ['sales/minimum_order/tax_including ' , ScopeInterface::SCOPE_STORE , 1 , true ]
285
+ ],
286
+ 'address ' => [
287
+ 'setBaseSubtotal ' => 25.00 ,
288
+ 'setBaseDiscountAmount ' => -27.60 ,
289
+ 'setBaseShippingDiscountAmount ' => 4.6 ,
290
+ 'setAddressType ' => 'shipping '
291
+ ],
292
+ 'quote ' => [
293
+ 'getStoreId ' => 1 ,
294
+ 'getIsVirtual ' => false
295
+ ],
296
+ 'result ' => true
297
+ ]
265
298
];
299
+ }
266
300
267
- $ this ->quote ->expects ($ this ->once ())
268
- ->method ('getStoreId ' )
269
- ->willReturn ($ storeId );
270
- $ this ->quote ->expects ($ this ->once ())
271
- ->method ('getIsVirtual ' )
272
- ->willReturn (false );
301
+ /**
302
+ * @dataProvider getDataProvider
303
+ * @return void
304
+ */
305
+ public function testValidateMinimumAmount (
306
+ array $ scopeConfigValues ,
307
+ array $ address ,
308
+ array $ quote ,
309
+ bool $ result
310
+ ): void {
311
+ foreach ($ quote as $ method => $ value ) {
312
+ $ this ->quote ->expects ($ this ->once ())
313
+ ->method ($ method )
314
+ ->willReturn ($ value );
315
+ }
316
+
317
+ foreach ($ address as $ setter => $ value ) {
318
+ $ this ->address ->$ setter ($ value );
319
+ }
273
320
274
321
$ this ->scopeConfig ->expects ($ this ->once ())
275
322
->method ('isSetFlag ' )
276
323
->willReturnMap ($ scopeConfigValues );
277
324
278
- $ this ->assertTrue ( $ this ->address ->validateMinimumAmount ());
325
+ $ this ->assertEquals ( $ result , $ this ->address ->validateMinimumAmount ());
279
326
}
280
327
281
328
/**
0 commit comments