1212use Magento \Framework \App \Request \Http as HttpRequest ;
1313use Magento \Framework \Serialize \SerializerInterface ;
1414use Magento \TestFramework \TestCase \AbstractBackendController ;
15+ use Magento \Eav \Model \Config ;
16+ use Magento \Catalog \Api \Data \ProductAttributeInterface ;
17+ use Magento \Framework \Exception \LocalizedException ;
1518
1619/**
1720 * Checks creating attribute options process.
2225 */
2326class CreateOptionsTest extends AbstractBackendController
2427{
28+ /**
29+ * @var ProductAttributeRepositoryInterface
30+ */
31+ private $ productAttributeRepository ;
32+
33+ /**
34+ * @var Config
35+ */
36+ private $ eavConfig ;
37+
2538 /**
2639 * @inheritdoc
2740 */
@@ -31,6 +44,8 @@ protected function setUp(): void
3144
3245 $ productRepository = $ this ->_objectManager ->get (ProductRepositoryInterface::class);
3346 $ productRepository ->cleanCache ();
47+ $ this ->productAttributeRepository = $ this ->_objectManager ->create (ProductAttributeRepositoryInterface::class);
48+ $ this ->eavConfig = $ this ->_objectManager ->create (Config::class);
3449 }
3550
3651 /**
@@ -76,4 +91,26 @@ protected function tearDown(): void
7691 }
7792 }
7893 }
94+
95+ /**
96+ * Test updating a product attribute and checking the frontend_class for the sku attribute.
97+ *
98+ * @magentoDataFixture Magento/Catalog/_files/product_attribute.php
99+ */
100+ public function testAttributeWithBackendTypeHasSameValueInFrontendClass ()
101+ {
102+ /** @var ProductAttributeInterface $attribute */
103+ $ attribute = $ this ->productAttributeRepository ->get ('sku ' );
104+
105+ $ attribute ->setFrontendClass ('my-custom-class ' );
106+
107+ $ this ->productAttributeRepository ->save ($ attribute );
108+
109+ try {
110+ $ skuAttribute = $ this ->eavConfig ->getAttribute ('catalog_product ' , 'sku ' );
111+ $ this ->assertEquals ('my-custom-class ' , $ skuAttribute ->getFrontendClass ());
112+ } catch (LocalizedException $ e ) {
113+ $ this ->fail ($ e ->getMessage ());
114+ }
115+ }
79116}
0 commit comments