CalculationTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Tax\Model\ResourceModel;
  7. class CalculationTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * Test that Tax Rate applied only once
  11. *
  12. * @magentoAppIsolation enabled
  13. * @magentoDataFixture Magento/Tax/_files/tax_classes.php
  14. */
  15. public function testGetRate()
  16. {
  17. /** @var $objectManager \Magento\TestFramework\ObjectManager */
  18. $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  19. $taxRule = $objectManager->get(\Magento\Framework\Registry::class)
  20. ->registry('_fixture/Magento_Tax_Model_Calculation_Rule');
  21. $customerTaxClasses = $taxRule->getCustomerTaxClassIds();
  22. $productTaxClasses = $taxRule->getProductTaxClassIds();
  23. $taxRate = $objectManager->get(\Magento\Framework\Registry::class)
  24. ->registry('_fixture/Magento_Tax_Model_Calculation_Rate');
  25. $data = new \Magento\Framework\DataObject();
  26. $data->setData(
  27. [
  28. 'tax_country_id' => 'US',
  29. 'taxregion_id' => '12',
  30. 'tax_postcode' => '5555',
  31. 'customer_class_id' => $customerTaxClasses[0],
  32. 'product_class_id' => $productTaxClasses[0],
  33. ]
  34. );
  35. $taxCalculation = $objectManager->get(\Magento\Tax\Model\ResourceModel\Calculation::class);
  36. $this->assertEquals($taxRate->getRateIds(), $taxCalculation->getRate($data));
  37. }
  38. }