Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
WeeeTest.php
Go to the documentation of this file.
1 <?php
7 
9 
13 class WeeeTest extends \PHPUnit\Framework\TestCase
14 {
18  protected $priceCurrency;
19 
23  protected $weeeCollector;
24 
25  private $serializerMock;
26 
33  protected function setupTaxHelper($taxConfig)
34  {
35  $taxHelper = $this->createMock(\Magento\Tax\Helper\Data::class);
36 
37  foreach ($taxConfig as $method => $value) {
38  $taxHelper->expects($this->any())->method($method)->will($this->returnValue($value));
39  }
40 
41  return $taxHelper;
42  }
43 
50  protected function setupTaxCalculation($taxRates)
51  {
52  $storeTaxRate = $taxRates['store_tax_rate'];
53  $customerTaxRate = $taxRates['customer_tax_rate'];
54 
55  $taxCalculation = $this->createPartialMock(
56  \Magento\Tax\Model\Calculation::class,
57  ['getRateOriginRequest', 'getRateRequest', 'getRate']
58  );
59 
60  $rateRequest = new \Magento\Framework\DataObject();
61  $defaultRateRequest = new \Magento\Framework\DataObject();
62 
63  $taxCalculation->expects($this->any())->method('getRateRequest')->will($this->returnValue($rateRequest));
64  $taxCalculation
65  ->expects($this->any())
66  ->method('getRateOriginRequest')
67  ->will($this->returnValue($defaultRateRequest));
68 
69  $taxCalculation
70  ->expects($this->any())
71  ->method('getRate')
72  ->will($this->onConsecutiveCalls($storeTaxRate, $customerTaxRate));
73 
74  return $taxCalculation;
75  }
76 
83  protected function setupWeeeHelper($weeeConfig)
84  {
85  $this->serializerMock = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)->getMock();
86 
87  $weeeHelper = $this->getMockBuilder(\Magento\Weee\Helper\Data::class)
88  ->setConstructorArgs(['serializer' => $this->serializerMock])
89  ->disableOriginalConstructor()
90  ->getMock();
91 
92  foreach ($weeeConfig as $method => $value) {
93  $weeeHelper->expects($this->any())->method($method)->will($this->returnValue($value));
94  }
95 
96  return $weeeHelper;
97  }
98 
105  protected function setupItemMockBasics($itemTotalQty)
106  {
107  $itemMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Item::class, [
108  'getProduct',
109  'getQuote',
110  'getAddress',
111  'getTotalQty',
112  'getParentItem',
113  'getHasChildren',
114  'getChildren',
115  'isChildrenCalculated',
116  '__wakeup',
117  ]);
118 
119  $productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
120  $itemMock->expects($this->any())->method('getProduct')->will($this->returnValue($productMock));
121  $itemMock->expects($this->any())->method('getTotalQty')->will($this->returnValue($itemTotalQty));
122 
123  return $itemMock;
124  }
125 
132  protected function setupItemMock($itemQty)
133  {
134  $itemMock = $this->setupItemMockBasics($itemQty);
135 
136  $itemMock->expects($this->any())->method('getParentItem')->will($this->returnValue(false));
137  $itemMock->expects($this->any())->method('getHasChildren')->will($this->returnValue(false));
138  $itemMock->expects($this->any())->method('getChildren')->will($this->returnValue([]));
139  $itemMock->expects($this->any())->method('isChildrenCalculated')->will($this->returnValue(false));
140 
141  return $itemMock;
142  }
143 
151  protected function setupParentItemWithChildrenMock($parentQty, $itemQty)
152  {
153  $items = [];
154 
155  $parentItemMock = $this->setupItemMockBasics($parentQty);
156 
157  $childItemMock = $this->setupItemMockBasics($parentQty * $itemQty);
158  $childItemMock->expects($this->any())->method('getParentItem')->will($this->returnValue($parentItemMock));
159  $childItemMock->expects($this->any())->method('getHasChildren')->will($this->returnValue(false));
160  $childItemMock->expects($this->any())->method('getChildren')->will($this->returnValue([]));
161  $childItemMock->expects($this->any())->method('isChildrenCalculated')->will($this->returnValue(false));
162 
163  $parentItemMock->expects($this->any())->method('getParentItem')->will($this->returnValue(false));
164  $parentItemMock->expects($this->any())->method('getHasChildren')->will($this->returnValue(true));
165  $parentItemMock->expects($this->any())->method('getChildren')->will($this->returnValue([$childItemMock]));
166  $parentItemMock->expects($this->any())->method('isChildrenCalculated')->will($this->returnValue(true));
167 
168  $items[] = $parentItemMock;
169  $items[] = $childItemMock;
170  return $items;
171  }
172 
179  protected function setupAddressMock($items)
180  {
181  $addressMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Address::class, [
182  '__wakeup',
183  'getAllItems',
184  'getQuote',
185  'getCustomAttributesCodes'
186  ]);
187 
188  $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
189  $storeMock = $this->createMock(\Magento\Store\Model\Store::class);
190  $this->priceCurrency = $this->getMockBuilder(
191  \Magento\Framework\Pricing\PriceCurrencyInterface::class
192  )->getMock();
193  $this->priceCurrency->expects($this->any())->method('round')->willReturnArgument(0);
194  $this->priceCurrency->expects($this->any())->method('convert')->willReturnArgument(0);
195  $quoteMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock));
196 
197  $addressMock->expects($this->any())->method('getAllItems')->will($this->returnValue($items));
198  $addressMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock));
199  $addressMock->expects($this->any())->method('getCustomAttributesCodes')->willReturn([]);
200 
201  return $addressMock;
202  }
203 
210  protected function setupShippingAssignmentMock($addressMock, $itemMock)
211  {
212  $shippingMock = $this->createMock(\Magento\Quote\Api\Data\ShippingInterface::class);
213  $shippingMock->expects($this->any())->method('getAddress')->willReturn($addressMock);
214  $shippingAssignmentMock = $this->createMock(\Magento\Quote\Api\Data\ShippingAssignmentInterface::class);
215  $shippingAssignmentMock->expects($this->any())->method('getItems')->willReturn($itemMock);
216  $shippingAssignmentMock->expects($this->any())->method('getShipping')->willReturn($shippingMock);
217 
218  return $shippingAssignmentMock;
219  }
220 
227  public function verifyItem(\Magento\Quote\Model\Quote\Item $item, $itemData)
228  {
229  foreach ($itemData as $key => $value) {
230  $this->assertEquals($value, $item->getData($key), 'item ' . $key . ' is incorrect');
231  }
232  }
233 
241  {
242  foreach ($addressData as $key => $value) {
243  $this->assertEquals($value, $address->getData($key), 'address ' . $key . ' is incorrect');
244  }
245  }
246 
260  public function testCollect(
261  $taxConfig,
262  $weeeConfig,
263  $taxRates,
264  $itemData,
265  $itemQty,
266  $parentQty,
267  $addressData,
268  $assertSetApplied = false
269  ) {
270  $items = [];
271  if ($parentQty > 0) {
272  $items = $this->setupParentItemWithChildrenMock($parentQty, $itemQty);
273  } else {
274  $itemMock = $this->setupItemMock($itemQty);
275  $items[] = $itemMock;
276  }
277  $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
278  $storeMock = $this->createMock(\Magento\Store\Model\Store::class);
279  $quoteMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock));
280  $addressMock = $this->setupAddressMock($items);
281  $totalMock = new \Magento\Quote\Model\Quote\Address\Total(
282  [],
283  $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)->getMock()
284  );
285  $shippingAssignmentMock = $this->setupShippingAssignmentMock($addressMock, $items);
286 
287  $taxHelper = $this->setupTaxHelper($taxConfig);
288  $weeeHelper = $this->setupWeeeHelper($weeeConfig);
289  $calculator = $this->setupTaxCalculation($taxRates);
290 
291  if ($assertSetApplied) {
292  $weeeHelper
293  ->expects($this->at(1))
294  ->method('setApplied')
295  ->with(reset($items), []);
296 
297  $weeeHelper
298  ->expects($this->at(2))
299  ->method('setApplied')
300  ->with(end($items), []);
301 
302  $weeeHelper
303  ->expects($this->at(8))
304  ->method('setApplied')
305  ->with(end($items), [
306  [
307  'title' => 'Recycling Fee',
308  'base_amount' => '10',
309  'amount' => '10',
310  'row_amount' => '20',
311  'base_row_amount' => '20',
312  'base_amount_incl_tax' => '10',
313  'amount_incl_tax' => '10',
314  'row_amount_incl_tax' => '20',
315  'base_row_amount_incl_tax' => '20',
316  ],
317  [
318  'title' => 'FPT Fee',
319  'base_amount' => '5',
320  'amount' => '5',
321  'row_amount' => '10',
322  'base_row_amount' => '10',
323  'base_amount_incl_tax' => '5',
324  'amount_incl_tax' => '5',
325  'row_amount_incl_tax' => '10',
326  'base_row_amount_incl_tax' => '10',
327  ]
328  ]);
329  }
330 
331  $arguments = [
332  'taxData' => $taxHelper,
333  'calculation' => $calculator,
334  'weeeData' => $weeeHelper,
335  'priceCurrency' => $this->priceCurrency
336  ];
337 
338  $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
339  $this->weeeCollector = $helper->getObject(\Magento\Weee\Model\Total\Quote\Weee::class, $arguments);
340 
341  $this->weeeCollector->collect($quoteMock, $shippingAssignmentMock, $totalMock);
342 
343  $this->verifyItem(end($items), $itemData); // verify the (child) item
344  $this->verifyAddress($totalMock, $addressData);
345  }
346 
355  public function collectDataProvider()
356  {
357  $data = [];
358 
359  // 1. This collector never computes tax. Instead it sets up various fields for the tax calculation.
360  // 2. When the Weee is not taxable, this collector will change the address data as follows:
361  // accumulate the totals into 'weee_total_excl_tax' and 'weee_base_total_excl_tax'
362 
363  $data['price_incl_tax_weee_taxable_unit_included_in_subtotal'] = [
364  'tax_config' => [
365  'priceIncludesTax' => true,
366  'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
367  ],
368  'weee_config' => [
369  'isEnabled' => true,
370  'includeInSubtotal' => true,
371  'isTaxable' => true,
372  'getApplied' => [],
373  'getProductWeeeAttributes' => [
374  new \Magento\Framework\DataObject(
375  [
376  'name' => 'Recycling Fee',
377  'amount' => 10,
378  ]
379  ),
380  ],
381  ],
382  'tax_rates' => [
383  'store_tax_rate' => 8.25,
384  'customer_tax_rate' => 8.25,
385  ],
386  'item' => [
387  'weee_tax_applied_amount' => 10,
388  'base_weee_tax_applied_amount' => 10,
389  'weee_tax_applied_row_amount' => 20,
390  'base_weee_tax_applied_row_amnt' => 20,
391  'weee_tax_applied_amount_incl_tax' => 10,
392  'base_weee_tax_applied_amount_incl_tax' => 10,
393  'weee_tax_applied_row_amount_incl_tax' => 20,
394  'base_weee_tax_applied_row_amnt_incl_tax' => 20,
395  ],
396  'item_qty' => 2,
397  'parent_qty' => 0,
398  'address_data' => [
399  'subtotal_incl_tax' => 20,
400  'base_subtotal_incl_tax' => 20,
401  ],
402  ];
403 
404  $data['price_incl_tax_weee_taxable_unit_not_included_in_subtotal'] = [
405  'tax_config' => [
406  'priceIncludesTax' => true,
407  'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
408  ],
409  'weee_config' => [
410  'isEnabled' => true,
411  'includeInSubtotal' => false,
412  'isTaxable' => true,
413  'getApplied' => [],
414  'getProductWeeeAttributes' => [
415  new \Magento\Framework\DataObject(
416  [
417  'name' => 'Recycling Fee',
418  'amount' => 10,
419  ]
420  ),
421  ],
422  ],
423  'tax_rates' => [
424  'store_tax_rate' => 8.25,
425  'customer_tax_rate' => 8.25,
426  ],
427  'item' => [
428  'weee_tax_applied_amount' => 10,
429  'base_weee_tax_applied_amount' => 10,
430  'weee_tax_applied_row_amount' => 20,
431  'base_weee_tax_applied_row_amnt' => 20,
432  'weee_tax_applied_amount_incl_tax' => 10,
433  'base_weee_tax_applied_amount_incl_tax' => 10,
434  'weee_tax_applied_row_amount_incl_tax' => 20,
435  'base_weee_tax_applied_row_amnt_incl_tax' => 20,
436  ],
437  'item_qty' => 2,
438  'parent_qty' => 0,
439  'address_data' => [
440  'subtotal_incl_tax' => 20,
441  'base_subtotal_incl_tax' => 20,
442  ],
443  ];
444 
445  $data['price_excl_tax_weee_taxable_unit_included_in_subtotal'] = [
446  'tax_config' => [
447  'priceIncludesTax' => false,
448  'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
449  ],
450  'weee_config' => [
451  'isEnabled' => true,
452  'includeInSubtotal' => true,
453  'isTaxable' => true,
454  'getApplied' => [],
455  'getProductWeeeAttributes' => [
456  new \Magento\Framework\DataObject(
457  [
458  'name' => 'Recycling Fee',
459  'amount' => 10,
460  ]
461  ),
462  ],
463  ],
464  'tax_rates' => [
465  'store_tax_rate' => 8.25,
466  'customer_tax_rate' => 8.25,
467  ],
468  'item' => [
469  'weee_tax_applied_amount' => 10,
470  'base_weee_tax_applied_amount' => 10,
471  'weee_tax_applied_row_amount' => 20,
472  'base_weee_tax_applied_row_amnt' => 20,
473  'weee_tax_applied_amount_incl_tax' => 10,
474  'base_weee_tax_applied_amount_incl_tax' => 10,
475  'weee_tax_applied_row_amount_incl_tax' => 20,
476  'base_weee_tax_applied_row_amnt_incl_tax' => 20,
477  ],
478  'item_qty' => 2,
479  'parent_qty' => 0,
480  'address_data' => [
481  'subtotal_incl_tax' => 20,
482  'base_subtotal_incl_tax' => 20,
483  ],
484  ];
485 
486  $data['price_incl_tax_weee_non_taxable_unit_included_in_subtotal'] = [
487  'tax_config' => [
488  'priceIncludesTax' => true,
489  'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
490  ],
491  'weee_config' => [
492  'isEnabled' => true,
493  'includeInSubtotal' => true,
494  'isTaxable' => false,
495  'getApplied' => [],
496  'getProductWeeeAttributes' => [
497  new \Magento\Framework\DataObject(
498  [
499  'name' => 'Recycling Fee',
500  'amount' => 10,
501  ]
502  ),
503  ],
504  ],
505  'tax_rates' => [
506  'store_tax_rate' => 8.25,
507  'customer_tax_rate' => 8.25,
508  ],
509  'item' => [
510  'weee_tax_applied_amount' => 10,
511  'base_weee_tax_applied_amount' => 10,
512  'weee_tax_applied_row_amount' => 20,
513  'base_weee_tax_applied_row_amnt' => 20,
514  'weee_tax_applied_amount_incl_tax' => 10,
515  'base_weee_tax_applied_amount_incl_tax' => 10,
516  'weee_tax_applied_row_amount_incl_tax' => 20,
517  'base_weee_tax_applied_row_amnt_incl_tax' => 20,
518  ],
519  'item_qty' => 2,
520  'parent_qty' => 0,
521  'address_data' => [
522  'subtotal_incl_tax' => 20,
523  'base_subtotal_incl_tax' => 20,
524  'weee_total_excl_tax' => 20,
525  'weee_base_total_excl_tax' => 20,
526  ],
527  ];
528 
529  $data['price_excl_tax_weee_non_taxable_unit_included_in_subtotal'] = [
530  'tax_config' => [
531  'priceIncludesTax' => false,
532  'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
533  ],
534  'weee_config' => [
535  'isEnabled' => true,
536  'includeInSubtotal' => true,
537  'isTaxable' => false,
538  'getApplied' => [],
539  'getProductWeeeAttributes' => [
540  new \Magento\Framework\DataObject(
541  [
542  'name' => 'Recycling Fee',
543  'amount' => 10,
544  ]
545  ),
546  ],
547  ],
548  'tax_rates' => [
549  'store_tax_rate' => 8.25,
550  'customer_tax_rate' => 8.25,
551  ],
552  'item' => [
553  'weee_tax_applied_amount' => 10,
554  'base_weee_tax_applied_amount' => 10,
555  'weee_tax_applied_row_amount' => 20,
556  'base_weee_tax_applied_row_amnt' => 20,
557  'weee_tax_applied_amount_incl_tax' => 10,
558  'base_weee_tax_applied_amount_incl_tax' => 10,
559  'weee_tax_applied_row_amount_incl_tax' => 20,
560  'base_weee_tax_applied_row_amnt_incl_tax' => 20,
561  ],
562  'item_qty' => 2,
563  'parent_qty' => 0,
564  'address_data' => [
565  'subtotal_incl_tax' => 20,
566  'base_subtotal_incl_tax' => 20,
567  'weee_total_excl_tax' => 20,
568  'weee_base_total_excl_tax' => 20,
569  ],
570  ];
571 
572  $data['price_incl_tax_weee_taxable_row_included_in_subtotal'] = [
573  'tax_config' => [
574  'priceIncludesTax' => true,
575  'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE,
576  ],
577  'weee_config' => [
578  'isEnabled' => true,
579  'includeInSubtotal' => true,
580  'isTaxable' => true,
581  'getApplied' => [],
582  'getProductWeeeAttributes' => [
583  new \Magento\Framework\DataObject(
584  [
585  'name' => 'Recycling Fee',
586  'amount' => 10,
587  ]
588  ),
589  ],
590  ],
591  'tax_rates' => [
592  'store_tax_rate' => 8.25,
593  'customer_tax_rate' => 8.25,
594  ],
595  'item' => [
596  'weee_tax_applied_amount' => 10,
597  'base_weee_tax_applied_amount' => 10,
598  'weee_tax_applied_row_amount' => 20,
599  'base_weee_tax_applied_row_amnt' => 20,
600  'weee_tax_applied_amount_incl_tax' => 10,
601  'base_weee_tax_applied_amount_incl_tax' => 10,
602  'weee_tax_applied_row_amount_incl_tax' => 20,
603  'base_weee_tax_applied_row_amnt_incl_tax' => 20,
604  ],
605  'item_qty' => 2,
606  'parent_qty' => 0,
607  'address_data' => [
608  'subtotal_incl_tax' => 20,
609  'base_subtotal_incl_tax' => 20,
610  ],
611  ];
612 
613  $data['price_excl_tax_weee_taxable_row_included_in_subtotal'] = [
614  'tax_config' => [
615  'priceIncludesTax' => false,
616  'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE,
617  ],
618  'weee_config' => [
619  'isEnabled' => true,
620  'includeInSubtotal' => true,
621  'isTaxable' => true,
622  'getApplied' => [],
623  'getProductWeeeAttributes' => [
624  new \Magento\Framework\DataObject(
625  [
626  'name' => 'Recycling Fee',
627  'amount' => 10,
628  ]
629  ),
630  ],
631  ],
632  'tax_rates' => [
633  'store_tax_rate' => 8.25,
634  'customer_tax_rate' => 8.25,
635  ],
636  'item' => [
637  'weee_tax_applied_amount' => 10,
638  'base_weee_tax_applied_amount' => 10,
639  'weee_tax_applied_row_amount' => 20,
640  'base_weee_tax_applied_row_amnt' => 20,
641  'weee_tax_applied_amount_incl_tax' => 10,
642  'base_weee_tax_applied_amount_incl_tax' => 10,
643  'weee_tax_applied_row_amount_incl_tax' => 20,
644  'base_weee_tax_applied_row_amnt_incl_tax' => 20,
645  ],
646  'item_qty' => 2,
647  'parent_qty' => 0,
648  'address_data' => [
649  'subtotal_incl_tax' => 20,
650  'base_subtotal_incl_tax' => 20,
651  ],
652  ];
653 
654  $data['price_incl_tax_weee_non_taxable_row_included_in_subtotal'] = [
655  'tax_config' => [
656  'priceIncludesTax' => true,
657  'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE,
658  ],
659  'weee_config' => [
660  'isEnabled' => true,
661  'includeInSubtotal' => true,
662  'isTaxable' => false,
663  'getApplied' => [],
664  'getProductWeeeAttributes' => [
665  new \Magento\Framework\DataObject(
666  [
667  'name' => 'Recycling Fee',
668  'amount' => 10,
669  ]
670  ),
671  ],
672  ],
673  'tax_rates' => [
674  'store_tax_rate' => 8.25,
675  'customer_tax_rate' => 8.25,
676  ],
677  'item' => [
678  'weee_tax_applied_amount' => 10,
679  'base_weee_tax_applied_amount' => 10,
680  'weee_tax_applied_row_amount' => 20,
681  'base_weee_tax_applied_row_amnt' => 20,
682  'weee_tax_applied_amount_incl_tax' => 10,
683  'base_weee_tax_applied_amount_incl_tax' => 10,
684  'weee_tax_applied_row_amount_incl_tax' => 20,
685  'base_weee_tax_applied_row_amnt_incl_tax' => 20,
686  ],
687  'item_qty' => 2,
688  'parent_qty' => 0,
689  'address_data' => [
690  'subtotal_incl_tax' => 20,
691  'base_subtotal_incl_tax' => 20,
692  'weee_total_excl_tax' => 20,
693  'weee_base_total_excl_tax' => 20,
694  ],
695  ];
696 
697  $data['price_excl_tax_weee_non_taxable_row_included_in_subtotal'] = [
698  'tax_config' => [
699  'priceIncludesTax' => false,
700  'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE,
701  ],
702  'weee_config' => [
703  'isEnabled' => true,
704  'includeInSubtotal' => true,
705  'isTaxable' => false,
706  'getApplied' => [],
707  'getProductWeeeAttributes' => [
708  new \Magento\Framework\DataObject(
709  [
710  'name' => 'Recycling Fee',
711  'amount' => 10,
712  ]
713  ),
714  ],
715  ],
716  'tax_rates' => [
717  'store_tax_rate' => 8.25,
718  'customer_tax_rate' => 8.25,
719  ],
720  'item' => [
721  'weee_tax_applied_amount' => 10,
722  'base_weee_tax_applied_amount' => 10,
723  'weee_tax_applied_row_amount' => 20,
724  'base_weee_tax_applied_row_amnt' => 20,
725  'weee_tax_applied_amount_incl_tax' => 10,
726  'base_weee_tax_applied_amount_incl_tax' => 10,
727  'weee_tax_applied_row_amount_incl_tax' => 20,
728  'base_weee_tax_applied_row_amnt_incl_tax' => 20,
729  ],
730  'item_qty' => 2,
731  'parent_qty' => 0,
732  'address_data' => [
733  'subtotal_incl_tax' => 20,
734  'base_subtotal_incl_tax' => 20,
735  'weee_total_excl_tax' => 20,
736  'weee_base_total_excl_tax' => 20,
737  ],
738  ];
739 
740  $data['price_excl_tax_weee_non_taxable_row_not_included_in_subtotal'] = [
741  'tax_config' => [
742  'priceIncludesTax' => false,
743  'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE,
744  ],
745  'weee_config' => [
746  'isEnabled' => true,
747  'includeInSubtotal' => false,
748  'isTaxable' => false,
749  'getApplied' => [],
750  'getProductWeeeAttributes' => [
751  new \Magento\Framework\DataObject(
752  [
753  'name' => 'Recycling Fee',
754  'amount' => 10,
755  ]
756  ),
757  ],
758  ],
759  'tax_rates' => [
760  'store_tax_rate' => 8.25,
761  'customer_tax_rate' => 8.25,
762  ],
763  'item' => [
764  'weee_tax_applied_amount' => 10,
765  'base_weee_tax_applied_amount' => 10,
766  'weee_tax_applied_row_amount' => 20,
767  'base_weee_tax_applied_row_amnt' => 20,
768  'weee_tax_applied_amount_incl_tax' => 10,
769  'base_weee_tax_applied_amount_incl_tax' => 10,
770  'weee_tax_applied_row_amount_incl_tax' => 20,
771  'base_weee_tax_applied_row_amnt_incl_tax' => 20,
772  ],
773  'item_qty' => 2,
774  'parent_qty' => 0,
775  'address_data' => [
776  'subtotal_incl_tax' => 20,
777  'base_subtotal_incl_tax' => 20,
778  'weee_total_excl_tax' => 20,
779  'weee_base_total_excl_tax' => 20,
780  ],
781  ];
782 
783  $data['price_excl_tax_weee_taxable_unit_not_included_in_subtotal_PARENT_ITEM'] = [
784  'tax_config' => [
785  'priceIncludesTax' => false,
786  'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
787  ],
788  'weee_config' => [
789  'isEnabled' => true,
790  'includeInSubtotal' => false,
791  'isTaxable' => true,
792  'getApplied' => [],
793  'getProductWeeeAttributes' => [
794  new \Magento\Framework\DataObject(
795  [
796  'name' => 'Recycling Fee',
797  'amount' => 10,
798  ]
799  ),
800  ],
801  ],
802  'tax_rates' => [
803  'store_tax_rate' => 8.25,
804  'customer_tax_rate' => 8.25,
805  ],
806  'item' => [
807  'weee_tax_applied_amount' => 10,
808  'base_weee_tax_applied_amount' => 10,
809  'weee_tax_applied_row_amount' => 60,
810  'base_weee_tax_applied_row_amnt' => 60,
811  'weee_tax_applied_amount_incl_tax' => 10,
812  'base_weee_tax_applied_amount_incl_tax' => 10,
813  'weee_tax_applied_row_amount_incl_tax' => 60,
814  'base_weee_tax_applied_row_amnt_incl_tax' => 60,
815  ],
816  'item_qty' => 2,
817  'parent_qty' => 3,
818  'address_data' => [
819  'subtotal_incl_tax' => 60,
820  'base_subtotal_incl_tax' => 60,
821  'weee_total_excl_tax' => 0,
822  'weee_base_total_excl_tax' => 0,
823  ],
824  ];
825 
826  $data['price_excl_tax_weee_non_taxable_row_not_included_in_subtotal_dynamic_multiple_weee'] = [
827  'tax_config' => [
828  'priceIncludesTax' => false,
829  'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE,
830  ],
831  'weee_config' => [
832  'isEnabled' => true,
833  'includeInSubtotal' => false,
834  'isTaxable' => false,
835  'getApplied' => [],
836  'getProductWeeeAttributes' => [
837  new \Magento\Framework\DataObject(
838  [
839  'name' => 'Recycling Fee',
840  'amount' => 10,
841  ]
842  ),
843  new \Magento\Framework\DataObject(
844  [
845  'name' => 'FPT Fee',
846  'amount' => 5,
847  ]
848  ),
849  ],
850  ],
851  'tax_rates' => [
852  'store_tax_rate' => 8.25,
853  'customer_tax_rate' => 8.25,
854  ],
855  'item' => [
856  'weee_tax_applied_amount' => 15,
857  'base_weee_tax_applied_amount' => 15,
858  'weee_tax_applied_row_amount' => 30,
859  'base_weee_tax_applied_row_amnt' => 30,
860  'weee_tax_applied_amount_incl_tax' => 15,
861  'base_weee_tax_applied_amount_incl_tax' => 15,
862  'weee_tax_applied_row_amount_incl_tax' => 30,
863  'base_weee_tax_applied_row_amnt_incl_tax' => 30,
864  ],
865  'item_qty' => 2,
866  'item_is_parent' => true,
867  'address_data' => [
868  'subtotal_incl_tax' => 30,
869  'base_subtotal_incl_tax' => 30,
870  'weee_total_excl_tax' => 30,
871  'weee_base_total_excl_tax' => 30,
872  ],
873  'assertSetApplied' => true,
874  ];
875 
876  return $data;
877  }
878 }
testCollect( $taxConfig, $weeeConfig, $taxRates, $itemData, $itemQty, $parentQty, $addressData, $assertSetApplied=false)
Definition: WeeeTest.php:260
$helper
Definition: iframe.phtml:13
verifyItem(\Magento\Quote\Model\Quote\Item $item, $itemData)
Definition: WeeeTest.php:227
$address
Definition: customer.php:38
$addressData
Definition: order.php:19
$value
Definition: gender.phtml:16
$method
Definition: info.phtml:13
setupShippingAssignmentMock($addressMock, $itemMock)
Definition: WeeeTest.php:210
$arguments
setupParentItemWithChildrenMock($parentQty, $itemQty)
Definition: WeeeTest.php:151
$items