Skip to content

Commit bd1c6c1

Browse files
akaashakaash
authored andcommitted
ACQE-4717 | Verify that attribute with backend_type=static has the same value in frontend_class fiield after saving
1 parent d2bacc2 commit bd1c6c1

File tree

1 file changed

+37
-0
lines changed
  • dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute

1 file changed

+37
-0
lines changed

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/CreateOptionsTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
use Magento\Framework\App\Request\Http as HttpRequest;
1313
use Magento\Framework\Serialize\SerializerInterface;
1414
use 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.
@@ -22,6 +25,16 @@
2225
*/
2326
class 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

Comments
 (0)