WeeeTest.php 33 KB

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