/**
  * @expectedException \Exception
  */
 public function testCreateTaxRuleExceptionOnSave()
 {
     $taxRuleBuilder = $this->objectManager->getObject('Magento\\Tax\\Service\\V1\\Data\\TaxRuleBuilder');
     $taxRule = $taxRuleBuilder->setId(2)->setCode('code')->setCustomerTaxClassIds([3])->setProductTaxClassIds([2])->setTaxRateIds([2])->setPriority(0)->setSortOrder(1)->create();
     $this->converterMock->expects($this->once())->method('createTaxRuleModel')->with($taxRule)->will($this->returnValue($this->ruleModelMock));
     $this->ruleModelMock->expects($this->once())->method('save')->will($this->throwException(new \Exception()));
     $this->taxRuleService->createTaxRule($taxRule);
 }
Esempio n. 2
0
 public function testCreateTaxRuleInvalidTaxClassIds()
 {
     $taxRuleBuilder = $this->objectManager->getObject('Magento\\Tax\\Service\\V1\\Data\\TaxRuleBuilder');
     $taxRule = $taxRuleBuilder->setCode('code')->setCustomerTaxClassIds([2])->setProductTaxClassIds([3])->setTaxRateIds([2])->setPriority(0)->setSortOrder(1)->create();
     try {
         //Tax rule service call
         $this->taxRuleService->createTaxRule($taxRule);
         $this->fail('Did not throw expected InputException');
     } catch (InputException $e) {
         $expectedCustomerTaxClassIdParams = ['fieldName' => $taxRule::CUSTOMER_TAX_CLASS_IDS, 'value' => 2];
         $expectedProductTaxClassIdParams = ['fieldName' => $taxRule::PRODUCT_TAX_CLASS_IDS, 'value' => 3];
         $actualErrors = $e->getErrors();
         $this->assertEquals(2, count($actualErrors));
         $this->assertEquals($expectedCustomerTaxClassIdParams, $actualErrors[0]->getParameters());
         $this->assertEquals($expectedProductTaxClassIdParams, $actualErrors[1]->getParameters());
     }
 }
Esempio n. 3
0
 /**
  * @magentoDbIsolation enabled
  * @expectedException \Magento\Framework\Exception\InputException
  * @expectedExceptionMessage code
  */
 public function testUpdateTaxRuleMissingRequiredFields()
 {
     $taxRuleServiceData = $this->taxRuleService->createTaxRule($this->createTaxRuleDataObject());
     $updatedTaxRule = $this->taxRuleBuilder->populate($taxRuleServiceData)->setCode(null)->create();
     $this->taxRuleService->updateTaxRule($updatedTaxRule);
 }