Example #1
0
 /**
  * {@inheritdoc}
  */
 public function deleteTaxRule($ruleId)
 {
     $ruleModel = $this->taxRuleRegistry->retrieveTaxRule($ruleId);
     $ruleModel->delete();
     $this->taxRuleRegistry->removeTaxRule($ruleId);
     return true;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function delete(TaxRuleInterface $rule)
 {
     $ruleId = $rule->getId();
     $this->resource->delete($rule);
     $this->taxRuleRegistry->removeTaxRule($ruleId);
     return true;
 }
 public function testRemoveTaxRule()
 {
     $this->taxRuleModelMock->expects($this->any())->method('load')->with(self::TAX_RULE_ID)->will($this->returnValue($this->taxRuleModelMock));
     $this->taxRuleModelMock->expects($this->any())->method('getId')->will($this->onConsecutiveCalls(self::TAX_RULE_ID, null));
     $this->taxRuleModelFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->taxRuleModelMock));
     $this->taxRuleRegistry->registerTaxRule($this->taxRuleModelMock);
     $expected = $this->taxRuleRegistry->retrieveTaxRule(self::TAX_RULE_ID);
     $this->assertEquals($this->taxRuleModelMock, $expected);
     // Remove the tax rule
     $this->taxRuleRegistry->removeTaxRule(self::TAX_RULE_ID);
     // Verify that if the tax rule is retrieved again, an exception is thrown
     try {
         $this->taxRuleRegistry->retrieveTaxRule(self::TAX_RULE_ID);
         $this->fail('NoSuchEntityException was not thrown as expected');
     } catch (NoSuchEntityException $e) {
         $expectedParams = ['fieldName' => 'taxRuleId', 'fieldValue' => self::TAX_RULE_ID];
         $this->assertEquals($expectedParams, $e->getParameters());
     }
 }