Skip to content

Commit 4b8970d

Browse files
akaashakaash
authored andcommitted
PR Feedback
1 parent 83d959e commit 4b8970d

File tree

2 files changed

+78
-45
lines changed

2 files changed

+78
-45
lines changed

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

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,9 @@
99

1010
use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
1111
use Magento\Catalog\Api\ProductRepositoryInterface;
12-
use Magento\ConfigurableProduct\Test\Fixture\Attribute as AttributeFixture;
1312
use Magento\Framework\App\Request\Http as HttpRequest;
14-
use Magento\Framework\Exception\LocalizedException;
1513
use Magento\Framework\Serialize\SerializerInterface;
16-
use Magento\TestFramework\Fixture\DataFixture;
1714
use Magento\TestFramework\TestCase\AbstractBackendController;
18-
use Magento\Eav\Model\Config;
19-
use Magento\Catalog\Api\Data\ProductAttributeInterface;
2015

2116
/**
2217
* Checks creating attribute options process.
@@ -27,16 +22,6 @@
2722
*/
2823
class CreateOptionsTest extends AbstractBackendController
2924
{
30-
/**
31-
* @var ProductAttributeRepositoryInterface
32-
*/
33-
private $productAttributeRepository;
34-
35-
/**
36-
* @var Config
37-
*/
38-
private $eavConfig;
39-
4025
/**
4126
* @inheritdoc
4227
*/
@@ -46,8 +31,6 @@ protected function setUp(): void
4631

4732
$productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
4833
$productRepository->cleanCache();
49-
$this->productAttributeRepository = $this->_objectManager->create(ProductAttributeRepositoryInterface::class);
50-
$this->eavConfig = $this->_objectManager->create(Config::class);
5134
}
5235

5336
/**
@@ -93,32 +76,4 @@ protected function tearDown(): void
9376
}
9477
}
9578
}
96-
97-
/**
98-
* Test updating a product attribute and checking the frontend_class for the sku attribute.
99-
*
100-
* @return void
101-
* @throws LocalizedException
102-
*/
103-
#[
104-
DataFixture(AttributeFixture::class, as: 'attr'),
105-
]
106-
public function testAttributeWithBackendTypeHasSameValueInFrontendClass()
107-
{
108-
// Load the 'sku' attribute.
109-
/** @var ProductAttributeInterface $attribute */
110-
$attribute = $this->productAttributeRepository->get('sku');
111-
$expectedFrontEndClass = $attribute->getFrontendClass();
112-
113-
// Save the attribute.
114-
$this->productAttributeRepository->save($attribute);
115-
116-
// Check that the frontend_class was updated correctly.
117-
try {
118-
$skuAttribute = $this->eavConfig->getAttribute('catalog_product', 'sku');
119-
$this->assertEquals($expectedFrontEndClass, $skuAttribute->getFrontendClass());
120-
} catch (LocalizedException $e) {
121-
$this->fail($e->getMessage());
122-
}
123-
}
12479
}
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 frontend_class was updated correctly.
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)