Skip to content

Commit d1cbcc0

Browse files
committed
MAGETWO-94819: Swatch validation breaks the whole attribute form
-- fix merge conflict
1 parent cc1433c commit d1cbcc0

File tree

2 files changed

+24
-1
lines changed
  • app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute
  • dev/tests/integration/testsuite/Magento/Swatches/Controller/Adminhtml/Product

2 files changed

+24
-1
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@
88
namespace Magento\Catalog\Controller\Adminhtml\Product\Attribute;
99

1010
use Magento\Catalog\Model\Product\Attribute\Option\OptionsDataSerializer;
11+
use Magento\Framework\App\Action\HttpGetActionInterface;
12+
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
1113
use Magento\Framework\App\ObjectManager;
1214
use Magento\Framework\DataObject;
15+
use Magento\Catalog\Controller\Adminhtml\Product\Attribute as AttributeAction;
1316

1417
/**
1518
* Product attribute validate controller.
1619
*
1720
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1821
*/
19-
class Validate extends \Magento\Catalog\Controller\Adminhtml\Product\Attribute
22+
class Validate extends AttributeAction implements HttpGetActionInterface, HttpPostActionInterface
2023
{
2124
const DEFAULT_MESSAGE_KEY = 'message';
2225

dev/tests/integration/testsuite/Magento/Swatches/Controller/Adminhtml/Product/AttributeTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Magento\Swatches\Controller\Adminhtml\Product;
99

10+
use Magento\Framework\App\Request\Http as HttpRequest;
11+
use Magento\Framework\Data\Form\FormKey;
1012
use Magento\Framework\Exception\LocalizedException;
1113

1214
/**
@@ -17,6 +19,21 @@
1719
*/
1820
class AttributeTest extends \Magento\TestFramework\TestCase\AbstractBackendController
1921
{
22+
/**
23+
* @var FormKey
24+
*/
25+
private $formKey;
26+
27+
/**
28+
* @inheritDoc
29+
*/
30+
protected function setUp()
31+
{
32+
parent::setUp();
33+
34+
$this->formKey = $this->_objectManager->get(FormKey::class);
35+
}
36+
2037
/**
2138
* Generate random hex color.
2239
*
@@ -116,6 +133,7 @@ private function getAttributePreset() : array
116133
{
117134
return [
118135
'form_key' => 'XxtpPYjm2YPYUlAt',
136+
'serialized_options' => '[]',
119137
'frontend_label' => [
120138
0 => 'asdasd',
121139
1 => '',
@@ -178,7 +196,9 @@ public function testLargeOptionsDataSet(
178196
int $expectedOptionsCount,
179197
array $expectedLabels
180198
) : void {
199+
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
181200
$this->getRequest()->setPostValue($attributeData);
201+
$this->getRequest()->setPostValue('form_key', $this->formKey->getFormKey());
182202
$this->dispatch('backend/catalog/product_attribute/save');
183203
$entityTypeId = $this->_objectManager->create(
184204
\Magento\Eav\Model\Entity::class

0 commit comments

Comments
 (0)