Skip to content

Commit 642e9f3

Browse files
Merge branch 'ACQE-4717' into integration-tests-mainline
2 parents 66cc162 + 04a652d commit 642e9f3

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\ConfigurableProduct\Controller\Adminhtml\Product\Attribute;
9+
10+
use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
11+
use Magento\Catalog\Api\ProductRepositoryInterface;
12+
use Magento\ConfigurableProduct\Test\Fixture\Attribute as AttributeFixture;
13+
use Magento\Framework\Exception\LocalizedException;
14+
use Magento\TestFramework\Fixture\DataFixture;
15+
use Magento\TestFramework\TestCase\AbstractBackendController;
16+
use Magento\Eav\Model\Config;
17+
use Magento\Catalog\Api\Data\ProductAttributeInterface;
18+
19+
/**
20+
* Checks creating attribute options process.
21+
*
22+
* @see \Magento\ConfigurableProduct\Controller\Adminhtml\Product\Attribute\UpdateProductAttributeTest
23+
* @magentoAppArea adminhtml
24+
* @magentoDbIsolation enabled
25+
*/
26+
class UpdateProductAttributeTest extends AbstractBackendController
27+
{
28+
/**
29+
* @var ProductAttributeRepositoryInterface
30+
*/
31+
private $productAttributeRepository;
32+
33+
/**
34+
* @var Config
35+
*/
36+
private $eavConfig;
37+
38+
/**
39+
* @inheritdoc
40+
*/
41+
protected function setUp(): void
42+
{
43+
parent::setUp();
44+
45+
$productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
46+
$productRepository->cleanCache();
47+
$this->productAttributeRepository = $this->_objectManager->create(ProductAttributeRepositoryInterface::class);
48+
$this->eavConfig = $this->_objectManager->create(Config::class);
49+
}
50+
51+
/**
52+
* Test updating a product attribute and checking the frontend_class for the sku attribute.
53+
*
54+
* @return void
55+
* @throws LocalizedException
56+
*/
57+
#[
58+
DataFixture(AttributeFixture::class, as: 'attr'),
59+
]
60+
public function testAttributeWithBackendTypeHasSameValueInFrontendClass()
61+
{
62+
// Load the 'sku' attribute.
63+
/** @var ProductAttributeInterface $attribute */
64+
$attribute = $this->productAttributeRepository->get('sku');
65+
$expectedFrontEndClass = $attribute->getFrontendClass();
66+
67+
// Save the attribute.
68+
$this->productAttributeRepository->save($attribute);
69+
70+
// Check that the value of the frontend_class changed or not.
71+
try {
72+
$skuAttribute = $this->eavConfig->getAttribute('catalog_product', 'sku');
73+
$this->assertEquals($expectedFrontEndClass, $skuAttribute->getFrontendClass());
74+
} catch (LocalizedException $e) {
75+
$this->fail($e->getMessage());
76+
}
77+
}
78+
}

0 commit comments

Comments
 (0)