![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/dev/tests/integration/testsuite/Magento/Tax/Model/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Tax\Model; use Magento\Customer\Api\AddressRepositoryInterface; use Magento\Customer\Api\GroupRepositoryInterface; use Magento\Customer\Api\CustomerRepositoryInterface; /** * Class CalculationTest * * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoDataFixture Magento/Customer/_files/customer_address.php */ class CalculationTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\TestFramework\ObjectManager */ protected $_objectManager; /** * @var CustomerRepositoryInterface */ protected $customerRepository; /** * @var AddressRepositoryInterface */ protected $addressRepository; /** * @var GroupRepositoryInterface */ protected $groupRepository; const FIXTURE_CUSTOMER_ID = 1; const FIXTURE_ADDRESS_ID = 1; /** * @var \Magento\Tax\Model\Calculation */ protected $_model; protected function setUp(): void { /** @var $objectManager \Magento\TestFramework\ObjectManager */ $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $this->_model = $this->_objectManager->create(\Magento\Tax\Model\Calculation::class); $this->customerRepository = $this->_objectManager->create( \Magento\Customer\Api\CustomerRepositoryInterface::class ); $this->addressRepository = $this->_objectManager->create( \Magento\Customer\Api\AddressRepositoryInterface::class ); $this->groupRepository = $this->_objectManager->create(\Magento\Customer\Api\GroupRepositoryInterface::class); } public function testDefaultCustomerTaxClass() { $defaultCustomerTaxClass = 3; $this->assertEquals($defaultCustomerTaxClass, $this->_model->getDefaultCustomerTaxClass(null)); } public function testGetDefaultRateRequest() { $customerDataSet = $this->customerRepository->getById(self::FIXTURE_CUSTOMER_ID); $address = $this->addressRepository->getById(self::FIXTURE_ADDRESS_ID); $rateRequest = $this->_model->getRateRequest(null, null, null, null, $customerDataSet->getId()); $this->assertNotNull($rateRequest); $this->assertEquals($address->getCountryId(), $rateRequest->getCountryId()); $this->assertEquals($address->getRegion()->getRegionId(), $rateRequest->getRegionId()); $this->assertEquals($address->getPostcode(), $rateRequest->getPostcode()); $customerTaxClassId = $this->groupRepository->getById($customerDataSet->getGroupId())->getTaxClassId(); $this->assertEquals($customerTaxClassId, $rateRequest->getCustomerClassId()); } }