예제 #1
0
 /**
  * @magentoDataFixture Magento/Tax/_files/tax_classes.php
  */
 public function testDeleteTaxRateException()
 {
     /** @var $registry \Magento\Framework\Registry */
     $registry = $this->objectManager->get('Magento\\Framework\\Registry');
     /** @var $taxRule \Magento\Tax\Model\Calculation\Rule */
     $taxRule = $registry->registry('_fixture/Magento_Tax_Model_Calculation_Rule');
     $this->assertNotNull($taxRule);
     $ruleId = $taxRule->getId();
     // Delete the new tax rate
     $this->assertTrue($this->taxRuleService->deleteTaxRule($ruleId));
     // Delete the new tax rate again, this should fail
     try {
         $this->taxRuleService->deleteTaxRule($ruleId);
         $this->fail('NoSuchEntityException expected but not thrown');
     } catch (NoSuchEntityException $e) {
         $expectedParams = ['fieldName' => 'taxRuleId', 'fieldValue' => $ruleId];
         $this->assertEquals($expectedParams, $e->getParameters());
     }
 }
예제 #2
0
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Bad error occurred
  */
 public function testDeleteTaxRuleDeleteException()
 {
     $this->ruleRegistryMock->expects($this->once())->method('retrieveTaxRule')->with(1)->will($this->returnValue($this->ruleModelMock));
     $this->ruleModelMock->expects($this->once())->method('delete')->will($this->throwException(new \Exception('Bad error occurred')));
     $this->taxRuleService->deleteTaxRule(1);
 }