Ejemplo n.º 1
0
 /**
  * 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));
     }
 }
Ejemplo n.º 2
0
 /**
  *
  * @param \Magento\Framework\Service\V1\Data\Filter[] $filters
  * @param \Magento\Framework\Service\V1\Data\Filter[] $filterGroup
  * @param $expectedRateCodes
  *
  * @magentoDbIsolation enabled
  * @dataProvider searchTaxRatesDataProvider
  */
 public function testSearchTaxRates($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\Service\V1\Data\SearchCriteriaBuilder $searchBuilder */
     $searchBuilder = Bootstrap::getObjectManager()->create('Magento\\Framework\\Service\\V1\\Data\\SearchCriteriaBuilder');
     foreach ($filters as $filter) {
         $searchBuilder->addFilter([$filter]);
     }
     if (!is_null($filterGroup)) {
         $searchBuilder->addFilter($filterGroup);
     }
     $searchCriteria = $searchBuilder->create();
     $searchResults = $this->taxRateService->searchTaxRates($searchCriteria);
     $items = [];
     foreach ($expectedRateCodes as $rateCode) {
         $rateId = $taxRates[$rateCode];
         $items[] = $this->taxRateService->getTaxRate($rateId);
     }
     $resultsBuilder = Bootstrap::getObjectManager()->create('Magento\\Tax\\Service\\V1\\Data\\TaxRateSearchResultsBuilder');
     $expectedResult = $resultsBuilder->setItems($items)->setTotalCount(count($items))->setSearchCriteria($searchCriteria)->create();
     $this->assertEquals($expectedResult, $searchResults);
 }
Ejemplo n.º 3
0
 /**
  * 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));
 }