Skip to content

Commit 54b2caf

Browse files
author
Cari Spruiell
committed
MAGETWO-64047: WebAPI: It's impossible to empty numeric fields after they're set
- fix tests
1 parent e70e590 commit 54b2caf

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function afterSave($object)
128128
$attribute = $this->getAttribute();
129129
$attributeCode = $attribute->getAttributeCode();
130130
$value = $object->getData($attributeCode);
131-
if ((float)$value > 0) {
131+
if ($value === null || (float)$value > 0) {
132132
if ($attribute->isScopeWebsite() && $object->getStoreId() != \Magento\Store\Model\Store::DEFAULT_STORE_ID) {
133133
if ($this->isUseDefault($object)) {
134134
$value = null;

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function testSaveAction($inputData, $defaultAttributes, $attributesSaved
5959
if ($exists !== $category->getExistsStoreValueFlag($attribute)) {
6060
if ($exists) {
6161
$errors[] = "custom value for '{$attribute}' attribute is not found";
62-
} else {
62+
} elseif (!$exists && $category->getCustomAttribute($attribute) !== null) {
6363
$errors[] = "custom value for '{$attribute}' attribute is found, but default one must be used";
6464
}
6565
}

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/AbstractProductExportImportTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ private function assertEqualsOtherThanSkippedAttributes($expected, $actual, $ski
155155

156156
$this->assertEquals(
157157
$value,
158-
$actual[$key],
158+
isset($actual[$key]) ? $actual[$key] : null,
159159
'Assert value at key - ' . $key . ' failed'
160160
);
161161
}

dev/tests/integration/testsuite/Magento/Eav/Model/ResourceModel/UpdateHandlerTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,12 @@ public function getCustomStoreDataProvider()
205205
return [
206206
['description', '', 'not_empty_value', 'not_empty_value'], //0
207207
['description', '', '', null], //1
208-
['description', '', null, 'Description with <b>html tag</b>'], //2
208+
['description', '', null, null], //2
209209
['description', '', false, 'Description with <b>html tag</b>'], //3
210210

211211
['description', 'not_empty_value', 'not_empty_value2', 'not_empty_value2'], //4
212212
['description', 'not_empty_value', '', null], //5
213-
['description', 'not_empty_value', null, 'Description with <b>html tag</b>'], //6
213+
['description', 'not_empty_value', null, null], //6
214214
['description', 'not_empty_value', false, 'Description with <b>html tag</b>'], //7
215215

216216
['description', null, 'not_empty_value', 'not_empty_value'], //8
@@ -219,7 +219,7 @@ public function getCustomStoreDataProvider()
219219

220220
['description', false, 'not_empty_value', 'not_empty_value'], //11
221221
['description', false, '', null], //12
222-
['description', false, null, 'Description with <b>html tag</b>'], //13
222+
['description', false, null, null], //13
223223
];
224224
}
225225

@@ -231,12 +231,12 @@ public function getCustomAttributeDataProvider()
231231
return [
232232
['dropdown_attribute', 0, '', 1, 1], //0
233233
['dropdown_attribute', 0, '', '', null], //1
234-
['dropdown_attribute', 0, '', null, 0], //2
234+
['dropdown_attribute', 0, '', null, null], //2
235235
['dropdown_attribute', 0, '', false, 0], //3
236236

237237
['dropdown_attribute', 0, 1, 2, 2], //4
238238
['dropdown_attribute', 0, 1, '', null], //5
239-
['dropdown_attribute', 0, 1, null, 0], //6
239+
['dropdown_attribute', 0, 1, null, null], //6
240240
['dropdown_attribute', 0, 1, false, 0], //7
241241

242242
['dropdown_attribute', 0, null, 1, 1], //8
@@ -245,11 +245,11 @@ public function getCustomAttributeDataProvider()
245245

246246
['dropdown_attribute', 0, false, 1, 1], //11
247247
['dropdown_attribute', 0, false, '', null], //12
248-
['dropdown_attribute', 0, false, null, 0], //13
248+
['dropdown_attribute', 0, false, null, null], //13
249249

250250
['dropdown_attribute', 0, '-', 1, 1], //14
251251
['dropdown_attribute', 0, '-', '', null], //15
252-
['dropdown_attribute', 0, '-', null, 0], //16
252+
['dropdown_attribute', 0, '-', null, null], //16
253253
['dropdown_attribute', 0, '-', false, 0], //17
254254
];
255255
}

0 commit comments

Comments
 (0)