/** * @magentoDbIsolation enabled */ public function testCreateTaxRuleInvalidSortOrder() { $taxRuleData = [TaxRule::CODE => 'code', TaxRule::CUSTOMER_TAX_CLASS_IDS => [3], TaxRule::PRODUCT_TAX_CLASS_IDS => [2], TaxRule::TAX_RATE_IDS => [1], TaxRule::PRIORITY => 0, TaxRule::SORT_ORDER => -1]; // Tax rule data object created $taxRule = $this->taxRuleBuilder->populateWithArray($taxRuleData)->create(); try { //Tax rule service call $this->taxRuleService->createTaxRule($taxRule); $this->fail('Did not throw expected InputException'); } catch (InputException $e) { $expectedParams = ['fieldName' => taxRule::SORT_ORDER, 'value' => -1, 'minValue' => '0']; $this->assertEquals($expectedParams, $e->getParameters()); $this->assertEquals(InputException::INVALID_FIELD_MIN_VALUE, $e->getRawMessage()); } }
/** * @param array $dataArray * @return TaxRuleSearchResults */ protected function generateDataObjectWithSetters($dataArray) { $this->builder->populateWithArray([]); if (array_key_exists(TaxRuleSearchResults::KEY_ITEMS, $dataArray)) { $items = []; foreach ($dataArray[TaxRuleSearchResults::KEY_ITEMS] as $itemArray) { $items[] = $this->taxRuleBuilder->populateWithArray($itemArray)->create(); } $this->builder->setItems($items); } if (array_key_exists(TaxRuleSearchResults::KEY_TOTAL_COUNT, $dataArray)) { $this->builder->setTotalCount($dataArray[TaxRuleSearchResults::KEY_TOTAL_COUNT]); } if (array_key_exists(TaxRuleSearchResults::KEY_SEARCH_CRITERIA, $dataArray)) { $this->builder->setSearchCriteria($this->searchCriteriaBuilder->populateWithArray($dataArray[TaxRuleSearchResults::KEY_SEARCH_CRITERIA])->create()); } return $this->builder->create(); }