/** * Helper function that tears down some default rules */ private function tearDownDefaultRules() { if ($this->taxRules) { $this->taxRuleFixtureFactory->deleteTaxRules(array_values($this->taxRules)); } if ($this->taxRates) { $this->taxRuleFixtureFactory->deleteTaxRates(array_values($this->taxRates)); } if ($this->taxClasses) { $this->taxRuleFixtureFactory->deleteTaxClasses(array_values($this->taxClasses)); } }
/** * * @param \Magento\Framework\Api\Filter[] $filters * @param \Magento\Framework\Api\Filter[] $filterGroup * @param $expectedRateCodes * * @magentoDbIsolation enabled * @dataProvider searchTaxRatesDataProvider * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ public function testGetList($filters, $filterGroup, $expectedRateCodes) { $taxRates = $this->taxRateFixtureFactory->createTaxRates([['percentage' => 7.5, 'country' => 'US', 'region' => '42'], ['percentage' => 7.5, 'country' => 'US', 'region' => '12'], ['percentage' => 22.0, 'country' => 'US', 'region' => '42'], ['percentage' => 10.0, 'country' => 'US', 'region' => '12']]); /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchBuilder */ $searchBuilder = Bootstrap::getObjectManager()->create('Magento\\Framework\\Api\\SearchCriteriaBuilder'); foreach ($filters as $filter) { $searchBuilder->addFilters([$filter]); } if ($filterGroup !== null) { $searchBuilder->addFilters($filterGroup); } $searchCriteria = $searchBuilder->create(); $searchResults = $this->rateRepository->getList($searchCriteria); $this->assertEquals($searchCriteria, $searchResults->getSearchCriteria()); $this->assertEquals(count($expectedRateCodes), $searchResults->getTotalCount()); foreach ($searchResults->getItems() as $rate) { $this->assertContains($rate->getCode(), $expectedRateCodes); } }
private function setUpDefaultRules() { $this->taxRates = $this->taxRuleFixtureFactory->createTaxRates([['percentage' => 7.5, 'country' => 'US', 'region' => 42], ['percentage' => 7.5, 'country' => 'US', 'region' => 12]]); $this->taxClasses = $this->taxRuleFixtureFactory->createTaxClasses([['name' => 'DefaultCustomerClass', 'type' => ClassModel::TAX_CLASS_TYPE_CUSTOMER], ['name' => 'DefaultProductClass', 'type' => ClassModel::TAX_CLASS_TYPE_PRODUCT], ['name' => 'HigherProductClass', 'type' => ClassModel::TAX_CLASS_TYPE_PRODUCT]]); $this->taxRules = $this->taxRuleFixtureFactory->createTaxRules([['code' => 'Default Rule', 'customer_tax_class_ids' => [$this->taxClasses['DefaultCustomerClass'], 3], 'product_tax_class_ids' => [$this->taxClasses['DefaultProductClass']], 'tax_rate_ids' => array_values($this->taxRates), 'sort_order' => 0, 'priority' => 0, 'calculate_subtotal' => 1]]); }
/** * Helper function that tears down some default rules */ public function tearDown() { $this->taxRuleFixtureFactory->deleteTaxRules(array_values($this->taxRules)); $this->taxRuleFixtureFactory->deleteTaxRates(array_values($this->taxRates)); $this->taxRuleFixtureFactory->deleteTaxClasses(array_values($this->taxClasses)); }