Example #1
0
 public function testUpdateTaxClassSaveFailure()
 {
     $taxClassId = 1;
     $taxClassSample = $this->taxClassBuilder->setClassType(TaxClassServiceInterface::TYPE_PRODUCT)->setClassName('Wholesale product')->create();
     $this->taxClassModelMock->expects($this->exactly(2))->method('getClassType')->will($this->returnValue(TaxClassServiceInterface::TYPE_PRODUCT));
     $this->converterMock->expects($this->once())->method('createTaxClassModel')->with($taxClassSample)->will($this->returnValue($this->taxClassModelMock));
     $this->taxClassModelMock->expects($this->once())->method('save')->will($this->throwException(new \Exception()));
     $this->assertFalse($this->taxClassService->updateTaxClass($taxClassId, $taxClassSample));
 }
 /**
  * @magentoDbIsolation enabled
  * @expectedException \Magento\Framework\Exception\InputException
  * @expectedExceptionMessage Updating classType is not allowed.
  */
 public function testUpdateTaxClassWithChangingClassType()
 {
     $taxClassName = 'New Class Name';
     $taxClassDataObject = $this->taxClassBuilder->setClassName($taxClassName)->setClassType(TaxClassModel::TAX_CLASS_TYPE_CUSTOMER)->create();
     $taxClassId = $this->taxClassService->createTaxClass($taxClassDataObject);
     $this->assertEquals($taxClassName, $this->taxClassModel->load($taxClassId)->getClassName());
     $updatedTaxClassName = 'Updated Class Name';
     $taxClassDataObject = $this->taxClassBuilder->setClassName($updatedTaxClassName)->setClassType(TaxClassModel::TAX_CLASS_TYPE_PRODUCT)->create();
     $this->taxClassService->updateTaxClass($taxClassId, $taxClassDataObject);
 }