123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Weee\Test\Unit\Model\Total\Quote;
- use Magento\Tax\Model\Calculation;
- /**
- * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
- */
- class WeeeTest extends \PHPUnit\Framework\TestCase
- {
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Pricing\PriceCurrencyInterface
- */
- protected $priceCurrency;
- /**
- * @var \Magento\Weee\Model\Total\Quote\Weee
- */
- protected $weeeCollector;
- private $serializerMock;
- /**
- * Setup tax helper with an array of methodName, returnValue
- *
- * @param array $taxConfig
- * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Tax\Helper\Data
- */
- protected function setupTaxHelper($taxConfig)
- {
- $taxHelper = $this->createMock(\Magento\Tax\Helper\Data::class);
- foreach ($taxConfig as $method => $value) {
- $taxHelper->expects($this->any())->method($method)->will($this->returnValue($value));
- }
- return $taxHelper;
- }
- /**
- * Setup calculator to return tax rates
- *
- * @param array $taxRates
- * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Tax\Model\Calculation
- */
- protected function setupTaxCalculation($taxRates)
- {
- $storeTaxRate = $taxRates['store_tax_rate'];
- $customerTaxRate = $taxRates['customer_tax_rate'];
- $taxCalculation = $this->createPartialMock(
- \Magento\Tax\Model\Calculation::class,
- ['getRateOriginRequest', 'getRateRequest', 'getRate']
- );
- $rateRequest = new \Magento\Framework\DataObject();
- $defaultRateRequest = new \Magento\Framework\DataObject();
- $taxCalculation->expects($this->any())->method('getRateRequest')->will($this->returnValue($rateRequest));
- $taxCalculation
- ->expects($this->any())
- ->method('getRateOriginRequest')
- ->will($this->returnValue($defaultRateRequest));
- $taxCalculation
- ->expects($this->any())
- ->method('getRate')
- ->will($this->onConsecutiveCalls($storeTaxRate, $customerTaxRate));
- return $taxCalculation;
- }
- /**
- * Setup weee helper with an array of methodName, returnValue
- *
- * @param array $weeeConfig
- * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Weee\Helper\Data
- */
- protected function setupWeeeHelper($weeeConfig)
- {
- $this->serializerMock = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)->getMock();
- $weeeHelper = $this->getMockBuilder(\Magento\Weee\Helper\Data::class)
- ->setConstructorArgs(['serializer' => $this->serializerMock])
- ->disableOriginalConstructor()
- ->getMock();
- foreach ($weeeConfig as $method => $value) {
- $weeeHelper->expects($this->any())->method($method)->will($this->returnValue($value));
- }
- return $weeeHelper;
- }
- /**
- * Setup the basics of an item mock
- *
- * @param float $itemTotalQty
- * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\Quote\Item
- */
- protected function setupItemMockBasics($itemTotalQty)
- {
- $itemMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Item::class, [
- 'getProduct',
- 'getQuote',
- 'getAddress',
- 'getTotalQty',
- 'getParentItem',
- 'getHasChildren',
- 'getChildren',
- 'isChildrenCalculated',
- '__wakeup',
- ]);
- $productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
- $itemMock->expects($this->any())->method('getProduct')->will($this->returnValue($productMock));
- $itemMock->expects($this->any())->method('getTotalQty')->will($this->returnValue($itemTotalQty));
- return $itemMock;
- }
- /**
- * Setup an item mock
- *
- * @param float $itemQty
- * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\Quote\Item
- */
- protected function setupItemMock($itemQty)
- {
- $itemMock = $this->setupItemMockBasics($itemQty);
- $itemMock->expects($this->any())->method('getParentItem')->will($this->returnValue(false));
- $itemMock->expects($this->any())->method('getHasChildren')->will($this->returnValue(false));
- $itemMock->expects($this->any())->method('getChildren')->will($this->returnValue([]));
- $itemMock->expects($this->any())->method('isChildrenCalculated')->will($this->returnValue(false));
- return $itemMock;
- }
- /**
- * Setup an item mock as a parent of a child item mock. Return both.
- *
- * @param float $parentQty
- * @param float $itemQty
- * @return \PHPUnit_Framework_MockObject_MockObject[]|\Magento\Quote\Model\Quote\Item[]
- */
- protected function setupParentItemWithChildrenMock($parentQty, $itemQty)
- {
- $items = [];
- $parentItemMock = $this->setupItemMockBasics($parentQty);
- $childItemMock = $this->setupItemMockBasics($parentQty * $itemQty);
- $childItemMock->expects($this->any())->method('getParentItem')->will($this->returnValue($parentItemMock));
- $childItemMock->expects($this->any())->method('getHasChildren')->will($this->returnValue(false));
- $childItemMock->expects($this->any())->method('getChildren')->will($this->returnValue([]));
- $childItemMock->expects($this->any())->method('isChildrenCalculated')->will($this->returnValue(false));
- $parentItemMock->expects($this->any())->method('getParentItem')->will($this->returnValue(false));
- $parentItemMock->expects($this->any())->method('getHasChildren')->will($this->returnValue(true));
- $parentItemMock->expects($this->any())->method('getChildren')->will($this->returnValue([$childItemMock]));
- $parentItemMock->expects($this->any())->method('isChildrenCalculated')->will($this->returnValue(true));
- $items[] = $parentItemMock;
- $items[] = $childItemMock;
- return $items;
- }
- /**
- * Setup address mock
- *
- * @param \PHPUnit_Framework_MockObject_MockObject[]|\Magento\Quote\Model\Quote\Item[] $items
- * @return \PHPUnit_Framework_MockObject_MockObject
- */
- protected function setupAddressMock($items)
- {
- $addressMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Address::class, [
- '__wakeup',
- 'getAllItems',
- 'getQuote',
- 'getCustomAttributesCodes'
- ]);
- $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
- $storeMock = $this->createMock(\Magento\Store\Model\Store::class);
- $this->priceCurrency = $this->getMockBuilder(
- \Magento\Framework\Pricing\PriceCurrencyInterface::class
- )->getMock();
- $this->priceCurrency->expects($this->any())->method('round')->willReturnArgument(0);
- $this->priceCurrency->expects($this->any())->method('convert')->willReturnArgument(0);
- $quoteMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock));
- $addressMock->expects($this->any())->method('getAllItems')->will($this->returnValue($items));
- $addressMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock));
- $addressMock->expects($this->any())->method('getCustomAttributesCodes')->willReturn([]);
- return $addressMock;
- }
- /**
- * Setup shipping assignment mock.
- * @param \PHPUnit_Framework_MockObject_MockObject $addressMock
- * @param \PHPUnit_Framework_MockObject_MockObject $itemMock
- * @return \PHPUnit_Framework_MockObject_MockObject
- */
- protected function setupShippingAssignmentMock($addressMock, $itemMock)
- {
- $shippingMock = $this->createMock(\Magento\Quote\Api\Data\ShippingInterface::class);
- $shippingMock->expects($this->any())->method('getAddress')->willReturn($addressMock);
- $shippingAssignmentMock = $this->createMock(\Magento\Quote\Api\Data\ShippingAssignmentInterface::class);
- $shippingAssignmentMock->expects($this->any())->method('getItems')->willReturn($itemMock);
- $shippingAssignmentMock->expects($this->any())->method('getShipping')->willReturn($shippingMock);
- return $shippingAssignmentMock;
- }
- /**
- * Verify that correct fields of item has been set
- *
- * @param \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\Quote\Item $item
- * @param $itemData
- */
- public function verifyItem(\Magento\Quote\Model\Quote\Item $item, $itemData)
- {
- foreach ($itemData as $key => $value) {
- $this->assertEquals($value, $item->getData($key), 'item ' . $key . ' is incorrect');
- }
- }
- /**
- * Verify that correct fields of address has been set
- *
- * @param \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\Quote\Address $address
- * @param $addressData
- */
- public function verifyAddress($address, $addressData)
- {
- foreach ($addressData as $key => $value) {
- $this->assertEquals($value, $address->getData($key), 'address ' . $key . ' is incorrect');
- }
- }
- /**
- * Test the collect function of the weee collector
- *
- * @param array $taxConfig
- * @param array $weeeConfig
- * @param array $taxRates
- * @param array $itemData
- * @param float $itemQty
- * @param float $parentQty
- * @param array $addressData
- * @param bool $assertSetApplied
- * @dataProvider collectDataProvider
- */
- public function testCollect(
- $taxConfig,
- $weeeConfig,
- $taxRates,
- $itemData,
- $itemQty,
- $parentQty,
- $addressData,
- $assertSetApplied = false
- ) {
- $items = [];
- if ($parentQty > 0) {
- $items = $this->setupParentItemWithChildrenMock($parentQty, $itemQty);
- } else {
- $itemMock = $this->setupItemMock($itemQty);
- $items[] = $itemMock;
- }
- $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
- $storeMock = $this->createMock(\Magento\Store\Model\Store::class);
- $quoteMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock));
- $addressMock = $this->setupAddressMock($items);
- $totalMock = new \Magento\Quote\Model\Quote\Address\Total(
- [],
- $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)->getMock()
- );
- $shippingAssignmentMock = $this->setupShippingAssignmentMock($addressMock, $items);
- $taxHelper = $this->setupTaxHelper($taxConfig);
- $weeeHelper = $this->setupWeeeHelper($weeeConfig);
- $calculator = $this->setupTaxCalculation($taxRates);
- if ($assertSetApplied) {
- $weeeHelper
- ->expects($this->at(1))
- ->method('setApplied')
- ->with(reset($items), []);
- $weeeHelper
- ->expects($this->at(2))
- ->method('setApplied')
- ->with(end($items), []);
- $weeeHelper
- ->expects($this->at(8))
- ->method('setApplied')
- ->with(end($items), [
- [
- 'title' => 'Recycling Fee',
- 'base_amount' => '10',
- 'amount' => '10',
- 'row_amount' => '20',
- 'base_row_amount' => '20',
- 'base_amount_incl_tax' => '10',
- 'amount_incl_tax' => '10',
- 'row_amount_incl_tax' => '20',
- 'base_row_amount_incl_tax' => '20',
- ],
- [
- 'title' => 'FPT Fee',
- 'base_amount' => '5',
- 'amount' => '5',
- 'row_amount' => '10',
- 'base_row_amount' => '10',
- 'base_amount_incl_tax' => '5',
- 'amount_incl_tax' => '5',
- 'row_amount_incl_tax' => '10',
- 'base_row_amount_incl_tax' => '10',
- ]
- ]);
- }
- $arguments = [
- 'taxData' => $taxHelper,
- 'calculation' => $calculator,
- 'weeeData' => $weeeHelper,
- 'priceCurrency' => $this->priceCurrency
- ];
- $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->weeeCollector = $helper->getObject(\Magento\Weee\Model\Total\Quote\Weee::class, $arguments);
- $this->weeeCollector->collect($quoteMock, $shippingAssignmentMock, $totalMock);
- $this->verifyItem(end($items), $itemData); // verify the (child) item
- $this->verifyAddress($totalMock, $addressData);
- }
- /**
- * Data provider for testCollect
- *
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
- * Multiple datasets
- *
- * @return array
- */
- public function collectDataProvider()
- {
- $data = [];
- // 1. This collector never computes tax. Instead it sets up various fields for the tax calculation.
- // 2. When the Weee is not taxable, this collector will change the address data as follows:
- // accumulate the totals into 'weee_total_excl_tax' and 'weee_base_total_excl_tax'
- $data['price_incl_tax_weee_taxable_unit_included_in_subtotal'] = [
- 'tax_config' => [
- 'priceIncludesTax' => true,
- 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
- ],
- 'weee_config' => [
- 'isEnabled' => true,
- 'includeInSubtotal' => true,
- 'isTaxable' => true,
- 'getApplied' => [],
- 'getProductWeeeAttributes' => [
- new \Magento\Framework\DataObject(
- [
- 'name' => 'Recycling Fee',
- 'amount' => 10,
- ]
- ),
- ],
- ],
- 'tax_rates' => [
- 'store_tax_rate' => 8.25,
- 'customer_tax_rate' => 8.25,
- ],
- 'item' => [
- 'weee_tax_applied_amount' => 10,
- 'base_weee_tax_applied_amount' => 10,
- 'weee_tax_applied_row_amount' => 20,
- 'base_weee_tax_applied_row_amnt' => 20,
- 'weee_tax_applied_amount_incl_tax' => 10,
- 'base_weee_tax_applied_amount_incl_tax' => 10,
- 'weee_tax_applied_row_amount_incl_tax' => 20,
- 'base_weee_tax_applied_row_amnt_incl_tax' => 20,
- ],
- 'item_qty' => 2,
- 'parent_qty' => 0,
- 'address_data' => [
- 'subtotal_incl_tax' => 20,
- 'base_subtotal_incl_tax' => 20,
- ],
- ];
- $data['price_incl_tax_weee_taxable_unit_not_included_in_subtotal'] = [
- 'tax_config' => [
- 'priceIncludesTax' => true,
- 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
- ],
- 'weee_config' => [
- 'isEnabled' => true,
- 'includeInSubtotal' => false,
- 'isTaxable' => true,
- 'getApplied' => [],
- 'getProductWeeeAttributes' => [
- new \Magento\Framework\DataObject(
- [
- 'name' => 'Recycling Fee',
- 'amount' => 10,
- ]
- ),
- ],
- ],
- 'tax_rates' => [
- 'store_tax_rate' => 8.25,
- 'customer_tax_rate' => 8.25,
- ],
- 'item' => [
- 'weee_tax_applied_amount' => 10,
- 'base_weee_tax_applied_amount' => 10,
- 'weee_tax_applied_row_amount' => 20,
- 'base_weee_tax_applied_row_amnt' => 20,
- 'weee_tax_applied_amount_incl_tax' => 10,
- 'base_weee_tax_applied_amount_incl_tax' => 10,
- 'weee_tax_applied_row_amount_incl_tax' => 20,
- 'base_weee_tax_applied_row_amnt_incl_tax' => 20,
- ],
- 'item_qty' => 2,
- 'parent_qty' => 0,
- 'address_data' => [
- 'subtotal_incl_tax' => 20,
- 'base_subtotal_incl_tax' => 20,
- ],
- ];
- $data['price_excl_tax_weee_taxable_unit_included_in_subtotal'] = [
- 'tax_config' => [
- 'priceIncludesTax' => false,
- 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
- ],
- 'weee_config' => [
- 'isEnabled' => true,
- 'includeInSubtotal' => true,
- 'isTaxable' => true,
- 'getApplied' => [],
- 'getProductWeeeAttributes' => [
- new \Magento\Framework\DataObject(
- [
- 'name' => 'Recycling Fee',
- 'amount' => 10,
- ]
- ),
- ],
- ],
- 'tax_rates' => [
- 'store_tax_rate' => 8.25,
- 'customer_tax_rate' => 8.25,
- ],
- 'item' => [
- 'weee_tax_applied_amount' => 10,
- 'base_weee_tax_applied_amount' => 10,
- 'weee_tax_applied_row_amount' => 20,
- 'base_weee_tax_applied_row_amnt' => 20,
- 'weee_tax_applied_amount_incl_tax' => 10,
- 'base_weee_tax_applied_amount_incl_tax' => 10,
- 'weee_tax_applied_row_amount_incl_tax' => 20,
- 'base_weee_tax_applied_row_amnt_incl_tax' => 20,
- ],
- 'item_qty' => 2,
- 'parent_qty' => 0,
- 'address_data' => [
- 'subtotal_incl_tax' => 20,
- 'base_subtotal_incl_tax' => 20,
- ],
- ];
- $data['price_incl_tax_weee_non_taxable_unit_included_in_subtotal'] = [
- 'tax_config' => [
- 'priceIncludesTax' => true,
- 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
- ],
- 'weee_config' => [
- 'isEnabled' => true,
- 'includeInSubtotal' => true,
- 'isTaxable' => false,
- 'getApplied' => [],
- 'getProductWeeeAttributes' => [
- new \Magento\Framework\DataObject(
- [
- 'name' => 'Recycling Fee',
- 'amount' => 10,
- ]
- ),
- ],
- ],
- 'tax_rates' => [
- 'store_tax_rate' => 8.25,
- 'customer_tax_rate' => 8.25,
- ],
- 'item' => [
- 'weee_tax_applied_amount' => 10,
- 'base_weee_tax_applied_amount' => 10,
- 'weee_tax_applied_row_amount' => 20,
- 'base_weee_tax_applied_row_amnt' => 20,
- 'weee_tax_applied_amount_incl_tax' => 10,
- 'base_weee_tax_applied_amount_incl_tax' => 10,
- 'weee_tax_applied_row_amount_incl_tax' => 20,
- 'base_weee_tax_applied_row_amnt_incl_tax' => 20,
- ],
- 'item_qty' => 2,
- 'parent_qty' => 0,
- 'address_data' => [
- 'subtotal_incl_tax' => 20,
- 'base_subtotal_incl_tax' => 20,
- 'weee_total_excl_tax' => 20,
- 'weee_base_total_excl_tax' => 20,
- ],
- ];
- $data['price_excl_tax_weee_non_taxable_unit_included_in_subtotal'] = [
- 'tax_config' => [
- 'priceIncludesTax' => false,
- 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
- ],
- 'weee_config' => [
- 'isEnabled' => true,
- 'includeInSubtotal' => true,
- 'isTaxable' => false,
- 'getApplied' => [],
- 'getProductWeeeAttributes' => [
- new \Magento\Framework\DataObject(
- [
- 'name' => 'Recycling Fee',
- 'amount' => 10,
- ]
- ),
- ],
- ],
- 'tax_rates' => [
- 'store_tax_rate' => 8.25,
- 'customer_tax_rate' => 8.25,
- ],
- 'item' => [
- 'weee_tax_applied_amount' => 10,
- 'base_weee_tax_applied_amount' => 10,
- 'weee_tax_applied_row_amount' => 20,
- 'base_weee_tax_applied_row_amnt' => 20,
- 'weee_tax_applied_amount_incl_tax' => 10,
- 'base_weee_tax_applied_amount_incl_tax' => 10,
- 'weee_tax_applied_row_amount_incl_tax' => 20,
- 'base_weee_tax_applied_row_amnt_incl_tax' => 20,
- ],
- 'item_qty' => 2,
- 'parent_qty' => 0,
- 'address_data' => [
- 'subtotal_incl_tax' => 20,
- 'base_subtotal_incl_tax' => 20,
- 'weee_total_excl_tax' => 20,
- 'weee_base_total_excl_tax' => 20,
- ],
- ];
- $data['price_incl_tax_weee_taxable_row_included_in_subtotal'] = [
- 'tax_config' => [
- 'priceIncludesTax' => true,
- 'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE,
- ],
- 'weee_config' => [
- 'isEnabled' => true,
- 'includeInSubtotal' => true,
- 'isTaxable' => true,
- 'getApplied' => [],
- 'getProductWeeeAttributes' => [
- new \Magento\Framework\DataObject(
- [
- 'name' => 'Recycling Fee',
- 'amount' => 10,
- ]
- ),
- ],
- ],
- 'tax_rates' => [
- 'store_tax_rate' => 8.25,
- 'customer_tax_rate' => 8.25,
- ],
- 'item' => [
- 'weee_tax_applied_amount' => 10,
- 'base_weee_tax_applied_amount' => 10,
- 'weee_tax_applied_row_amount' => 20,
- 'base_weee_tax_applied_row_amnt' => 20,
- 'weee_tax_applied_amount_incl_tax' => 10,
- 'base_weee_tax_applied_amount_incl_tax' => 10,
- 'weee_tax_applied_row_amount_incl_tax' => 20,
- 'base_weee_tax_applied_row_amnt_incl_tax' => 20,
- ],
- 'item_qty' => 2,
- 'parent_qty' => 0,
- 'address_data' => [
- 'subtotal_incl_tax' => 20,
- 'base_subtotal_incl_tax' => 20,
- ],
- ];
- $data['price_excl_tax_weee_taxable_row_included_in_subtotal'] = [
- 'tax_config' => [
- 'priceIncludesTax' => false,
- 'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE,
- ],
- 'weee_config' => [
- 'isEnabled' => true,
- 'includeInSubtotal' => true,
- 'isTaxable' => true,
- 'getApplied' => [],
- 'getProductWeeeAttributes' => [
- new \Magento\Framework\DataObject(
- [
- 'name' => 'Recycling Fee',
- 'amount' => 10,
- ]
- ),
- ],
- ],
- 'tax_rates' => [
- 'store_tax_rate' => 8.25,
- 'customer_tax_rate' => 8.25,
- ],
- 'item' => [
- 'weee_tax_applied_amount' => 10,
- 'base_weee_tax_applied_amount' => 10,
- 'weee_tax_applied_row_amount' => 20,
- 'base_weee_tax_applied_row_amnt' => 20,
- 'weee_tax_applied_amount_incl_tax' => 10,
- 'base_weee_tax_applied_amount_incl_tax' => 10,
- 'weee_tax_applied_row_amount_incl_tax' => 20,
- 'base_weee_tax_applied_row_amnt_incl_tax' => 20,
- ],
- 'item_qty' => 2,
- 'parent_qty' => 0,
- 'address_data' => [
- 'subtotal_incl_tax' => 20,
- 'base_subtotal_incl_tax' => 20,
- ],
- ];
- $data['price_incl_tax_weee_non_taxable_row_included_in_subtotal'] = [
- 'tax_config' => [
- 'priceIncludesTax' => true,
- 'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE,
- ],
- 'weee_config' => [
- 'isEnabled' => true,
- 'includeInSubtotal' => true,
- 'isTaxable' => false,
- 'getApplied' => [],
- 'getProductWeeeAttributes' => [
- new \Magento\Framework\DataObject(
- [
- 'name' => 'Recycling Fee',
- 'amount' => 10,
- ]
- ),
- ],
- ],
- 'tax_rates' => [
- 'store_tax_rate' => 8.25,
- 'customer_tax_rate' => 8.25,
- ],
- 'item' => [
- 'weee_tax_applied_amount' => 10,
- 'base_weee_tax_applied_amount' => 10,
- 'weee_tax_applied_row_amount' => 20,
- 'base_weee_tax_applied_row_amnt' => 20,
- 'weee_tax_applied_amount_incl_tax' => 10,
- 'base_weee_tax_applied_amount_incl_tax' => 10,
- 'weee_tax_applied_row_amount_incl_tax' => 20,
- 'base_weee_tax_applied_row_amnt_incl_tax' => 20,
- ],
- 'item_qty' => 2,
- 'parent_qty' => 0,
- 'address_data' => [
- 'subtotal_incl_tax' => 20,
- 'base_subtotal_incl_tax' => 20,
- 'weee_total_excl_tax' => 20,
- 'weee_base_total_excl_tax' => 20,
- ],
- ];
- $data['price_excl_tax_weee_non_taxable_row_included_in_subtotal'] = [
- 'tax_config' => [
- 'priceIncludesTax' => false,
- 'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE,
- ],
- 'weee_config' => [
- 'isEnabled' => true,
- 'includeInSubtotal' => true,
- 'isTaxable' => false,
- 'getApplied' => [],
- 'getProductWeeeAttributes' => [
- new \Magento\Framework\DataObject(
- [
- 'name' => 'Recycling Fee',
- 'amount' => 10,
- ]
- ),
- ],
- ],
- 'tax_rates' => [
- 'store_tax_rate' => 8.25,
- 'customer_tax_rate' => 8.25,
- ],
- 'item' => [
- 'weee_tax_applied_amount' => 10,
- 'base_weee_tax_applied_amount' => 10,
- 'weee_tax_applied_row_amount' => 20,
- 'base_weee_tax_applied_row_amnt' => 20,
- 'weee_tax_applied_amount_incl_tax' => 10,
- 'base_weee_tax_applied_amount_incl_tax' => 10,
- 'weee_tax_applied_row_amount_incl_tax' => 20,
- 'base_weee_tax_applied_row_amnt_incl_tax' => 20,
- ],
- 'item_qty' => 2,
- 'parent_qty' => 0,
- 'address_data' => [
- 'subtotal_incl_tax' => 20,
- 'base_subtotal_incl_tax' => 20,
- 'weee_total_excl_tax' => 20,
- 'weee_base_total_excl_tax' => 20,
- ],
- ];
- $data['price_excl_tax_weee_non_taxable_row_not_included_in_subtotal'] = [
- 'tax_config' => [
- 'priceIncludesTax' => false,
- 'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE,
- ],
- 'weee_config' => [
- 'isEnabled' => true,
- 'includeInSubtotal' => false,
- 'isTaxable' => false,
- 'getApplied' => [],
- 'getProductWeeeAttributes' => [
- new \Magento\Framework\DataObject(
- [
- 'name' => 'Recycling Fee',
- 'amount' => 10,
- ]
- ),
- ],
- ],
- 'tax_rates' => [
- 'store_tax_rate' => 8.25,
- 'customer_tax_rate' => 8.25,
- ],
- 'item' => [
- 'weee_tax_applied_amount' => 10,
- 'base_weee_tax_applied_amount' => 10,
- 'weee_tax_applied_row_amount' => 20,
- 'base_weee_tax_applied_row_amnt' => 20,
- 'weee_tax_applied_amount_incl_tax' => 10,
- 'base_weee_tax_applied_amount_incl_tax' => 10,
- 'weee_tax_applied_row_amount_incl_tax' => 20,
- 'base_weee_tax_applied_row_amnt_incl_tax' => 20,
- ],
- 'item_qty' => 2,
- 'parent_qty' => 0,
- 'address_data' => [
- 'subtotal_incl_tax' => 20,
- 'base_subtotal_incl_tax' => 20,
- 'weee_total_excl_tax' => 20,
- 'weee_base_total_excl_tax' => 20,
- ],
- ];
- $data['price_excl_tax_weee_taxable_unit_not_included_in_subtotal_PARENT_ITEM'] = [
- 'tax_config' => [
- 'priceIncludesTax' => false,
- 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE,
- ],
- 'weee_config' => [
- 'isEnabled' => true,
- 'includeInSubtotal' => false,
- 'isTaxable' => true,
- 'getApplied' => [],
- 'getProductWeeeAttributes' => [
- new \Magento\Framework\DataObject(
- [
- 'name' => 'Recycling Fee',
- 'amount' => 10,
- ]
- ),
- ],
- ],
- 'tax_rates' => [
- 'store_tax_rate' => 8.25,
- 'customer_tax_rate' => 8.25,
- ],
- 'item' => [
- 'weee_tax_applied_amount' => 10,
- 'base_weee_tax_applied_amount' => 10,
- 'weee_tax_applied_row_amount' => 60,
- 'base_weee_tax_applied_row_amnt' => 60,
- 'weee_tax_applied_amount_incl_tax' => 10,
- 'base_weee_tax_applied_amount_incl_tax' => 10,
- 'weee_tax_applied_row_amount_incl_tax' => 60,
- 'base_weee_tax_applied_row_amnt_incl_tax' => 60,
- ],
- 'item_qty' => 2,
- 'parent_qty' => 3,
- 'address_data' => [
- 'subtotal_incl_tax' => 60,
- 'base_subtotal_incl_tax' => 60,
- 'weee_total_excl_tax' => 0,
- 'weee_base_total_excl_tax' => 0,
- ],
- ];
- $data['price_excl_tax_weee_non_taxable_row_not_included_in_subtotal_dynamic_multiple_weee'] = [
- 'tax_config' => [
- 'priceIncludesTax' => false,
- 'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE,
- ],
- 'weee_config' => [
- 'isEnabled' => true,
- 'includeInSubtotal' => false,
- 'isTaxable' => false,
- 'getApplied' => [],
- 'getProductWeeeAttributes' => [
- new \Magento\Framework\DataObject(
- [
- 'name' => 'Recycling Fee',
- 'amount' => 10,
- ]
- ),
- new \Magento\Framework\DataObject(
- [
- 'name' => 'FPT Fee',
- 'amount' => 5,
- ]
- ),
- ],
- ],
- 'tax_rates' => [
- 'store_tax_rate' => 8.25,
- 'customer_tax_rate' => 8.25,
- ],
- 'item' => [
- 'weee_tax_applied_amount' => 15,
- 'base_weee_tax_applied_amount' => 15,
- 'weee_tax_applied_row_amount' => 30,
- 'base_weee_tax_applied_row_amnt' => 30,
- 'weee_tax_applied_amount_incl_tax' => 15,
- 'base_weee_tax_applied_amount_incl_tax' => 15,
- 'weee_tax_applied_row_amount_incl_tax' => 30,
- 'base_weee_tax_applied_row_amnt_incl_tax' => 30,
- ],
- 'item_qty' => 2,
- 'item_is_parent' => true,
- 'address_data' => [
- 'subtotal_incl_tax' => 30,
- 'base_subtotal_incl_tax' => 30,
- 'weee_total_excl_tax' => 30,
- 'weee_base_total_excl_tax' => 30,
- ],
- 'assertSetApplied' => true,
- ];
- return $data;
- }
- }
|