12
12
use Magento \Framework \App \Request \Http as HttpRequest ;
13
13
use Magento \Framework \Serialize \SerializerInterface ;
14
14
use Magento \TestFramework \TestCase \AbstractBackendController ;
15
+ use Magento \Eav \Model \Config ;
16
+ use Magento \Catalog \Api \Data \ProductAttributeInterface ;
17
+ use Magento \Framework \Exception \LocalizedException ;
15
18
16
19
/**
17
20
* Checks creating attribute options process.
22
25
*/
23
26
class CreateOptionsTest extends AbstractBackendController
24
27
{
28
+ /**
29
+ * @var ProductAttributeRepositoryInterface
30
+ */
31
+ private $ productAttributeRepository ;
32
+
33
+ /**
34
+ * @var Config
35
+ */
36
+ private $ eavConfig ;
37
+
25
38
/**
26
39
* @inheritdoc
27
40
*/
@@ -31,6 +44,8 @@ protected function setUp(): void
31
44
32
45
$ productRepository = $ this ->_objectManager ->get (ProductRepositoryInterface::class);
33
46
$ productRepository ->cleanCache ();
47
+ $ this ->productAttributeRepository = $ this ->_objectManager ->create (ProductAttributeRepositoryInterface::class);
48
+ $ this ->eavConfig = $ this ->_objectManager ->create (Config::class);
34
49
}
35
50
36
51
/**
@@ -76,4 +91,26 @@ protected function tearDown(): void
76
91
}
77
92
}
78
93
}
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
+ }
79
116
}
0 commit comments