Skip to content

Commit c9c067d

Browse files
committed
MAGETWO-50123: Unable to assign blank value to attribute #3545 #4910 #5485 #5225
- fix & add code to integration test with new logic
1 parent 9368800 commit c9c067d

File tree

3 files changed

+119
-1
lines changed

3 files changed

+119
-1
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/EavTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,19 @@ public function testModifyMeta()
7070
$this->prepareDataForComparison($actualMeta, $expectedMeta);
7171
$this->assertEquals($expectedMeta, $actualMeta);
7272
}
73+
74+
public function testModifyMetaNewProduct()
75+
{
76+
$this->objectManager->get(\Magento\Eav\Model\Entity\AttributeCache::class)->clear();
77+
/** @var \Magento\Catalog\Model\Product $product */
78+
$product = $this->objectManager->create(\Magento\Catalog\Model\Product::class);
79+
$product->setAttributeSetId(4);
80+
$this->locatorMock->expects($this->any())->method('getProduct')->willReturn($product);
81+
$expectedMeta = include __DIR__ . '/_files/eav_expected_meta_output_w_default.php';
82+
$actualMeta = $this->eavModifier->modifyMeta([]);
83+
$this->prepareDataForComparison($actualMeta, $expectedMeta);
84+
$this->assertEquals($expectedMeta, $actualMeta);
85+
}
7386

7487
/**
7588
* @magentoDataFixture Magento/Catalog/_files/product_simple_with_admin_store.php

dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/_files/eav_expected_meta_output.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"visible" => "1",
3636
"required" => "0",
3737
"label" => "Enable Product",
38-
"default" => "1",
38+
"default" => null,
3939
"source" => "product-details",
4040
"scopeLabel" => "[WEBSITE]",
4141
"globalScope" => false,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
return [
8+
"product-details" => [
9+
"arguments" => [
10+
"data" => [
11+
"config" => [
12+
"dataScope" => "data.product",
13+
],
14+
],
15+
],
16+
"children" => [
17+
"container_status" => [
18+
"children" => [
19+
"status" => [
20+
"arguments" => [
21+
"data" => [
22+
"config" => [
23+
"dataType" => "select",
24+
"formElement" => "select",
25+
"options" => [
26+
[
27+
"value" => 1,
28+
"label" => "Enabled"
29+
],
30+
[
31+
"value" => 2,
32+
"label" => "Disabled"
33+
]
34+
],
35+
"visible" => "1",
36+
"required" => "0",
37+
"label" => "Enable Product",
38+
"default" => "1",
39+
"source" => "product-details",
40+
"scopeLabel" => "[WEBSITE]",
41+
"globalScope" => false,
42+
"code" => "status",
43+
"sortOrder" => "__placeholder__",
44+
"componentType" => "field"
45+
],
46+
],
47+
],
48+
],
49+
],
50+
],
51+
"container_name" => [
52+
"children" => [
53+
"name" => [
54+
"arguments" => [
55+
"data" => [
56+
"config" => [
57+
"dataType" => "text",
58+
"formElement" => "input",
59+
"visible" => "1",
60+
"required" => "1",
61+
"label" => "Product Name",
62+
"source" => "product-details",
63+
"scopeLabel" => "[STORE VIEW]",
64+
"globalScope" => false,
65+
"code" => "name",
66+
"sortOrder" => "__placeholder__",
67+
"componentType" => "field",
68+
"validation" => [
69+
"required-entry" => true
70+
],
71+
],
72+
],
73+
],
74+
],
75+
],
76+
],
77+
"container_sku" => [
78+
"children" => [
79+
"sku" => [
80+
"arguments" => [
81+
"data" => [
82+
"config" => [
83+
"dataType" => "text",
84+
"formElement" => "input",
85+
"visible" => "1",
86+
"required" => "1",
87+
"label" => "SKU",
88+
"source" => "product-details",
89+
"scopeLabel" => "[GLOBAL]",
90+
"globalScope" => true,
91+
"code" => "sku",
92+
"sortOrder" => "__placeholder__",
93+
"componentType" => "field",
94+
"validation" => [
95+
"required-entry" => true
96+
],
97+
],
98+
],
99+
],
100+
],
101+
],
102+
],
103+
],
104+
],
105+
];

0 commit comments

Comments
 (0)