8 class ClassTest extends \PHPUnit\Framework\TestCase
15 protected function setUp()
24 public function testCheckClassCanBeDeletedCustomerClassAssertException()
27 $model = $this->_objectManager->create(
28 \
Magento\Tax\Model\ClassModel::class
29 )->getCollection()->setClassTypeFilter(
33 $this->expectException(\
Magento\Framework\Exception\CouldNotDeleteException::class);
40 public function testCheckClassCanBeDeletedProductClassAssertException()
43 $model = $this->_objectManager->create(
44 \
Magento\Tax\Model\ClassModel::class
45 )->getCollection()->setClassTypeFilter(
49 $this->_objectManager->create(
50 \
Magento\Catalog\Model\Product::class
65 )->setMetaDescription(
68 \
Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
70 \
Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
75 $this->expectException(\
Magento\Framework\Exception\CouldNotDeleteException::class);
83 public function testCheckClassCanBeDeletedPositiveResult($classType)
86 $model = $this->_objectManager->create(\
Magento\Tax\Model\ClassModel::class);
87 $model->setClassName(
'TaxClass' . uniqid())->setClassType($classType)->isObjectNew(
true);
105 public function testCheckClassCanBeDeletedCustomerClassUsedInTaxRule()
111 $customerClasses =
$taxRule->getCustomerTaxClasses();
114 $model = $this->_objectManager->create(\
Magento\Tax\Model\ClassModel::class)->load($customerClasses[0]);
115 $this->expectException(\
Magento\Framework\Exception\CouldNotDeleteException::class);
116 $this->expectExceptionMessage(
'You cannot delete this tax class because it is used in' .
117 ' Tax Rules. You have to delete the rules it is used in first.');
125 public function testCheckClassCanBeDeletedProductClassUsedInTaxRule()
131 $productClasses =
$taxRule->getProductTaxClasses();
134 $model = $this->_objectManager->create(\
Magento\Tax\Model\ClassModel::class)->load($productClasses[0]);
135 $this->expectException(\
Magento\Framework\Exception\CouldNotDeleteException::class);
136 $this->expectExceptionMessage(
'You cannot delete this tax class because it is used in' .
137 ' Tax Rules. You have to delete the rules it is used in first.');
const TAX_CLASS_TYPE_CUSTOMER
const TAX_CLASS_TYPE_PRODUCT
static getObjectManager()