/** * @magentoDbIsolation enabled * @expectedException \Magento\Framework\Exception\InputException * @expectedExceptionMessage class_id is not expected for this request. */ public function testCreateTaxClass() { $taxClassDataObject = $this->taxClassBuilder->setClassName(self::SAMPLE_TAX_CLASS_NAME)->setClassType(TaxClassServiceInterface::TYPE_CUSTOMER)->create(); $taxClassId = $this->taxClassService->createTaxClass($taxClassDataObject); $this->assertEquals(self::SAMPLE_TAX_CLASS_NAME, $this->taxClassModel->load($taxClassId)->getClassName()); //Create another one with created id. Make sure its not updating the existing Tax class $taxClassDataObject = $this->taxClassBuilder->setClassId($taxClassId)->setClassName(self::SAMPLE_TAX_CLASS_NAME . uniqid())->setClassType(TaxClassServiceInterface::TYPE_CUSTOMER)->create(); //Should not be allowed to set the classId. Will throw InputException $this->taxClassService->createTaxClass($taxClassDataObject); }
/** * @expectedException \Magento\Framework\Exception\InputException * @expectedExceptionMessage class_id is not expected for this request. */ public function testUpdateTaxClassWithClassIdInDataObject() { $taxClassId = 1; $taxClassSample = $this->taxClassBuilder->setClassId($taxClassId)->setClassName('Wholesale product')->create(); $this->taxClassService->updateTaxClass($taxClassId, $taxClassSample); }
/** * 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(); }