|
9 | 9 |
|
10 | 10 | use Magento\Catalog\Api\ProductAttributeRepositoryInterface; |
11 | 11 | use Magento\Catalog\Api\ProductRepositoryInterface; |
| 12 | +use Magento\ConfigurableProduct\Test\Fixture\Attribute as AttributeFixture; |
12 | 13 | use Magento\Framework\App\Request\Http as HttpRequest; |
| 14 | +use Magento\Framework\Exception\LocalizedException; |
13 | 15 | use Magento\Framework\Serialize\SerializerInterface; |
| 16 | +use Magento\TestFramework\Fixture\DataFixture; |
14 | 17 | use Magento\TestFramework\TestCase\AbstractBackendController; |
15 | 18 | use Magento\Eav\Model\Config; |
16 | 19 | use Magento\Catalog\Api\Data\ProductAttributeInterface; |
17 | | -use Magento\Framework\Exception\LocalizedException; |
18 | 20 |
|
19 | 21 | /** |
20 | 22 | * Checks creating attribute options process. |
@@ -95,20 +97,26 @@ protected function tearDown(): void |
95 | 97 | /** |
96 | 98 | * Test updating a product attribute and checking the frontend_class for the sku attribute. |
97 | 99 | * |
98 | | - * @magentoDataFixture Magento/Catalog/_files/product_attribute.php |
| 100 | + * @return void |
| 101 | + * @throws LocalizedException |
99 | 102 | */ |
| 103 | + #[ |
| 104 | + DataFixture(AttributeFixture::class, as: 'attr'), |
| 105 | + ] |
100 | 106 | public function testAttributeWithBackendTypeHasSameValueInFrontendClass() |
101 | 107 | { |
| 108 | + // Load the 'sku' attribute. |
102 | 109 | /** @var ProductAttributeInterface $attribute */ |
103 | 110 | $attribute = $this->productAttributeRepository->get('sku'); |
| 111 | + $expectedFrontEndClass = $attribute->getFrontendClass(); |
104 | 112 |
|
105 | | - $attribute->setFrontendClass('my-custom-class'); |
106 | | - |
| 113 | + // Save the attribute. |
107 | 114 | $this->productAttributeRepository->save($attribute); |
108 | 115 |
|
| 116 | + // Check that the frontend_class was updated correctly. |
109 | 117 | try { |
110 | 118 | $skuAttribute = $this->eavConfig->getAttribute('catalog_product', 'sku'); |
111 | | - $this->assertEquals('my-custom-class', $skuAttribute->getFrontendClass()); |
| 119 | + $this->assertEquals($expectedFrontEndClass, $skuAttribute->getFrontendClass()); |
112 | 120 | } catch (LocalizedException $e) { |
113 | 121 | $this->fail($e->getMessage()); |
114 | 122 | } |
|
0 commit comments