Skip to content

Commit d084053

Browse files
committed
MAGETWO-94819: Swatch validation breaks the whole attribute form
1 parent d83c61c commit d084053

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function execute()
140140
{
141141
try {
142142
$optionData = $this->optionsDataSerializer
143-
->unserialize($this->getRequest()->getParam('serialized_options'));
143+
->unserialize($this->getRequest()->getParam('serialized_options', '[]'));
144144
} catch (\InvalidArgumentException $e) {
145145
$message = __("The attribute couldn't be saved due to an error. Verify your information and try again. "
146146
. "If the error persists, please try again later.");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function execute()
8383
$response->setError(false);
8484
try {
8585
$optionsData = $this->optionsDataSerializer
86-
->unserialize($this->getRequest()->getParam('serialized_options'));
86+
->unserialize($this->getRequest()->getParam('serialized_options', '[]'));
8787
} catch (\InvalidArgumentException $e) {
8888
$message = __("The attribute couldn't be validated due to an error. Verify your information and try again. "
8989
. "If the error persists, please try again later.");

app/code/Magento/Catalog/Test/Mftf/Test/AdminEditTextEditorProductAttributeTest.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@
2626
<requiredEntity createDataKey="myProductAttributeCreation"/>
2727
</createData>
2828
</before>
29-
<amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="navigateToProductAttributeGrid1"/>
30-
<waitForPageLoad stepKey="waitForPageLoad1"/>
31-
<click selector="{{AdminProductAttributeGridSection.AttributeCode($$myProductAttributeCreation.attribute_code$$)}}" stepKey="navigateToAttributeEditPage1" />
32-
<waitForPageLoad stepKey="waitForPageLoad2" />
29+
<actionGroup ref="navigateToCreatedProductAttribute" stepKey="navigateToAttribute">
30+
<argument name="ProductAttribute" value="productAttributeWysiwyg"/>
31+
</actionGroup>
3332
<seeOptionIsSelected selector="{{AttributePropertiesSection.InputType}}" userInput="Text Editor" stepKey="seeTextEditorSelected" />
3433
<see selector="{{AttributePropertiesSection.InputType}}" userInput="Text Area" stepKey="seeTextArea1" />
3534
<selectOption selector="{{AttributePropertiesSection.InputType}}" userInput="Text Area" stepKey="selectTextArea" />

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/SaveTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public function testExecuteWithEmptyData()
180180
->method('getParam')
181181
->willReturnMap([
182182
['isAjax', null, null],
183-
['serialized_options', null, ''],
183+
['serialized_options', '[]', ''],
184184
]);
185185
$this->optionsDataSerializerMock
186186
->expects($this->once())
@@ -211,7 +211,7 @@ public function testExecute()
211211
->method('getParam')
212212
->willReturnMap([
213213
['isAjax', null, null],
214-
['serialized_options', null, ''],
214+
['serialized_options', '[]', ''],
215215
]);
216216
$this->optionsDataSerializerMock
217217
->expects($this->once())
@@ -271,7 +271,7 @@ public function testExecuteWithOptionsDataError()
271271
->method('getParam')
272272
->willReturnMap([
273273
['isAjax', null, true],
274-
['serialized_options', null, $serializedOptions],
274+
['serialized_options', '[]', $serializedOptions],
275275
]);
276276
$this->optionsDataSerializerMock
277277
->expects($this->once())

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/ValidateTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function testExecute()
130130
['frontend_label', null, 'test_frontend_label'],
131131
['attribute_code', null, 'test_attribute_code'],
132132
['new_attribute_set_name', null, 'test_attribute_set_name'],
133-
['serialized_options', null, $serializedOptions],
133+
['serialized_options', '[]', $serializedOptions],
134134
]);
135135
$this->objectManagerMock->expects($this->exactly(2))
136136
->method('create')
@@ -181,7 +181,7 @@ public function testUniqueValidation(array $options, $isError)
181181
['attribute_code', null, "test_attribute_code"],
182182
['new_attribute_set_name', null, 'test_attribute_set_name'],
183183
['message_key', null, Validate::DEFAULT_MESSAGE_KEY],
184-
['serialized_options', null, $serializedOptions],
184+
['serialized_options', '[]', $serializedOptions],
185185
]);
186186

187187
$this->optionsDataSerializerMock
@@ -316,7 +316,7 @@ public function testEmptyOption(array $options, $result)
316316
['attribute_code', null, "test_attribute_code"],
317317
['new_attribute_set_name', null, 'test_attribute_set_name'],
318318
['message_key', Validate::DEFAULT_MESSAGE_KEY, 'message'],
319-
['serialized_options', null, $serializedOptions],
319+
['serialized_options', '[]', $serializedOptions],
320320
]);
321321

322322
$this->optionsDataSerializerMock
@@ -428,7 +428,7 @@ public function testExecuteWithOptionsDataError()
428428
['attribute_code', null, 'test_attribute_code'],
429429
['new_attribute_set_name', null, 'test_attribute_set_name'],
430430
['message_key', Validate::DEFAULT_MESSAGE_KEY, 'message'],
431-
['serialized_options', null, $serializedOptions],
431+
['serialized_options', '[]', $serializedOptions],
432432
]);
433433

434434
$this->optionsDataSerializerMock

0 commit comments

Comments
 (0)