Beispiel #1
0
 /**
  * @expectedException \Magento\Framework\Model\Exception
  */
 public function testCreateTaxRateWithModelException()
 {
     $taxData = ['country_id' => 'US', 'region_id' => '8', 'percentage_rate' => '8.25', 'code' => 'US-CA-*-Rate', 'zip_range' => ['from' => 78765, 'to' => 78780]];
     $taxRateDataObject = $this->taxRateBuilder->populateWithArray($taxData)->create();
     $this->rateModelMock->expects($this->once())->method('save')->will($this->throwException(new \Magento\Framework\Model\Exception()));
     $this->converterMock->expects($this->once())->method('createTaxRateModel')->will($this->returnValue($this->rateModelMock));
     $this->taxRateService->createTaxRate($taxRateDataObject);
 }
Beispiel #2
0
 /**
  * @magentoDbIsolation enabled
  */
 public function testDeleteTaxRateException()
 {
     // Create a new tax rate
     $taxRateData = $this->taxRateBuilder->setCode('TX')->setCountryId('US')->setPercentageRate(6)->setPostcode(77001)->setRegionId(1)->create();
     $taxRateId = $this->taxRateService->createTaxRate($taxRateData)->getId();
     // Delete the new tax rate
     $this->assertTrue($this->taxRateService->deleteTaxRate($taxRateId));
     // Delete the new tax rate again, this should fail
     try {
         $this->taxRateService->deleteTaxRate($taxRateId);
         $this->fail('NoSuchEntityException expected but not thrown');
     } catch (NoSuchEntityException $e) {
         $expectedParams = ['fieldName' => 'taxRateId', 'fieldValue' => $taxRateId];
         $this->assertEquals($expectedParams, $e->getParameters());
     } catch (\Exception $e) {
         $this->fail('Caught unexpected exception');
     }
 }