Ejemplo n.º 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));
 }
Ejemplo n.º 2
0
 /**
  * @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);
 }
Ejemplo n.º 3
0
 /**
  * @magentoDbIsolation enabled
  */
 public function testGetTaxClassId()
 {
     $taxClassName = 'Get Me';
     $taxClassDataObject = $this->taxClassBuilder->setClassName($taxClassName)->setClassType(TaxClassServiceInterface::TYPE_CUSTOMER)->create();
     $taxClassId = $this->taxClassService->createTaxClass($taxClassDataObject);
     /** @var \Magento\Tax\Service\V1\Data\TaxClassKeyBuilder $taxClassKeyBuilder */
     $taxClassKeyBuilder = $this->objectManager->create('Magento\\Tax\\Service\\V1\\Data\\TaxClassKeyBuilder');
     $taxClassKeyTypeId = $taxClassKeyBuilder->populateWithArray([TaxClassKey::KEY_TYPE => TaxClassKey::TYPE_ID, TaxClassKey::KEY_VALUE => $taxClassId])->create();
     $this->assertEquals($taxClassId, $this->taxClassService->getTaxClassId($taxClassKeyTypeId, TaxClassServiceInterface::TYPE_CUSTOMER));
     $taxClassKeyTypeName = $taxClassKeyBuilder->populateWithArray([TaxClassKey::KEY_TYPE => TaxClassKey::TYPE_NAME, TaxClassKey::KEY_VALUE => $taxClassName])->create();
     $this->assertEquals($taxClassId, $this->taxClassService->getTaxClassId($taxClassKeyTypeId, TaxClassServiceInterface::TYPE_CUSTOMER));
     $this->assertNull($this->taxClassService->getTaxClassId(null));
     $this->assertEquals(null, $this->taxClassService->getTaxClassId($taxClassKeyTypeName, TaxClassServiceInterface::TYPE_PRODUCT));
 }
Ejemplo n.º 4
0
 /**
  * Convert tax class model into tax class service data object.
  *
  * @param TaxClassModel $taxClassModel
  * @return TaxClass
  */
 public function createTaxClassData(TaxClassModel $taxClassModel)
 {
     $this->taxClassBuilder->setClassId($taxClassModel->getId())->setClassName($taxClassModel->getClassName())->setClassType($taxClassModel->getClassType());
     return $this->taxClassBuilder->create();
 }