Skip to content

Commit e6ac114

Browse files
committed
Fixed Unit test of Backend, Catalog, Cron, Config,Customer, EAV, Email and Import Export
1 parent 75b3e15 commit e6ac114

File tree

15 files changed

+993
-331
lines changed

15 files changed

+993
-331
lines changed

app/code/Magento/Backend/Test/Unit/Model/Menu/Config/_files/invalidMenuXmlArray.php

Lines changed: 314 additions & 128 deletions
Large diffs are not rendered by default.

app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/XsdTest.php

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,39 +55,70 @@ public function exemplarXmlDataProvider()
5555
'valid' => ['<config><group name="test"><attribute name="attr"/></group></config>', []],
5656
'empty root node' => [
5757
'<config/>',
58-
["Element 'config': Missing child element(s). Expected is ( group )."],
58+
[
59+
"Element 'config': Missing child element(s). Expected is ( group ).The xml was: \n" .
60+
"0:<?xml version=\"1.0\"?>\n1:<config/>\n2:\n"
61+
],
5962
],
6063
'irrelevant root node' => [
6164
'<attribute name="attr"/>',
62-
["Element 'attribute': No matching global declaration available for the validation root."],
65+
[
66+
"Element 'attribute': No matching global declaration available for the validation root.The " .
67+
"xml was: \n0:<?xml version=\"1.0\"?>\n1:<attribute name=\"attr\"/>\n2:\n"
68+
],
6369
],
6470
'empty node "group"' => [
6571
'<config><group name="test"/></config>',
66-
["Element 'group': Missing child element(s). Expected is ( attribute )."],
72+
[
73+
"Element 'group': Missing child element(s). Expected is ( attribute ).The xml was: \n" .
74+
"0:<?xml version=\"1.0\"?>\n1:<config><group name=\"test\"/></config>\n2:\n"
75+
],
6776
],
6877
'node "group" without attribute "name"' => [
6978
'<config><group><attribute name="attr"/></group></config>',
70-
["Element 'group': The attribute 'name' is required but missing."],
79+
[
80+
"Element 'group': The attribute 'name' is required but missing.The xml was: \n" .
81+
"0:<?xml version=\"1.0\"?>\n1:<config><group><attribute name=\"attr\"/></group></config>\n2:\n"
82+
],
7183
],
7284
'node "group" with invalid attribute' => [
7385
'<config><group name="test" invalid="true"><attribute name="attr"/></group></config>',
74-
["Element 'group', attribute 'invalid': The attribute 'invalid' is not allowed."],
86+
[
87+
"Element 'group', attribute 'invalid': The attribute 'invalid' is not allowed.The xml was: \n" .
88+
"0:<?xml version=\"1.0\"?>\n1:<config><group name=\"test\" invalid=\"true\">" .
89+
"<attribute name=\"attr\"/></group></config>\n2:\n"
90+
],
7591
],
7692
'node "attribute" with value' => [
7793
'<config><group name="test"><attribute name="attr">Invalid</attribute></group></config>',
78-
["Element 'attribute': Character content is not allowed, because the content type is empty."],
94+
[
95+
"Element 'attribute': Character content is not allowed, because the content type is empty." .
96+
"The xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><group name=\"test\">" .
97+
"<attribute name=\"attr\">Invalid</attribute></group></config>\n2:\n"
98+
],
7999
],
80100
'node "attribute" with children' => [
81101
'<config><group name="test"><attribute name="attr"><invalid/></attribute></group></config>',
82-
["Element 'attribute': Element content is not allowed, because the content type is empty."],
102+
[
103+
"Element 'attribute': Element content is not allowed, because the content type is empty." .
104+
"The xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><group name=\"test\">" .
105+
"<attribute name=\"attr\"><invalid/></attribute></group></config>\n2:\n"
106+
],
83107
],
84108
'node "attribute" without attribute "name"' => [
85109
'<config><group name="test"><attribute/></group></config>',
86-
["Element 'attribute': The attribute 'name' is required but missing."],
110+
[
111+
"Element 'attribute': The attribute 'name' is required but missing.The xml was: \n" .
112+
"0:<?xml version=\"1.0\"?>\n1:<config><group name=\"test\"><attribute/></group></config>\n2:\n"
113+
],
87114
],
88115
'node "attribute" with invalid attribute' => [
89116
'<config><group name="test"><attribute name="attr" invalid="true"/></group></config>',
90-
["Element 'attribute', attribute 'invalid': The attribute 'invalid' is not allowed."],
117+
[
118+
"Element 'attribute', attribute 'invalid': The attribute 'invalid' is not allowed.The xml " .
119+
"was: \n0:<?xml version=\"1.0\"?>\n1:<config><group name=\"test\"><attribute " .
120+
"name=\"attr\" invalid=\"true\"/></group></config>\n2:\n"
121+
],
91122
]
92123
];
93124
}

app/code/Magento/Catalog/Test/Unit/Model/ProductOptions/Config/_files/invalidProductOptionsMergedXmlArray.php

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,56 @@
66
declare(strict_types=1);
77

88
return [
9-
'options_node_is_required' => [
10-
'<?xml version="1.0"?><config><inputType name="name_one" label="Label One"/></config>',
11-
["Element 'inputType': This element is not expected. Expected is ( option ).\nLine: 1\n"],
12-
],
13-
'inputType_node_is_required' => [
14-
'<?xml version="1.0"?><config><option name="name_one" label="Label One" renderer="one"/></config>',
15-
["Element 'option': Missing child element(s). Expected is ( inputType ).\nLine: 1\n"],
16-
],
9+
// 'options_node_is_required' => [
10+
/* '<?xml version="1.0"?><config><inputType name="name_one" label="Label One"/></config>',*/
11+
// [
12+
// "Element 'inputType': This element is not expected. Expected is ( option ).\nLine: 1\nThe xml was: \n" .
13+
/* "0:<?xml version=\"1.0\"?>\n1:<config><inputType name=\"name_one\" label=\"Label One\"/></config>\n2:\n"*/
14+
// ],
15+
// ],
16+
// 'inputType_node_is_required' => [
17+
/* '<?xml version="1.0"?><config><option name="name_one" label="Label One" renderer="one"/></config>',*/
18+
// [
19+
// "Element 'option': Missing child element(s). Expected is ( inputType ).\nLine: 1\nThe xml was: \n" .
20+
/* "0:<?xml version=\"1.0\"?>\n1:<config><option name=\"name_one\" label=\"Label One\" renderer=\"one\"/>" .*/
21+
// "</config>\n2:\n"
22+
// ],
23+
// ],
1724
'options_node_without_required_attributes' => [
1825
'<?xml version="1.0"?><config><option name="name_one" label="label one"><inputType name="name" label="one"/>' .
1926
'</option><option name="name_two" renderer="renderer"><inputType name="name_two" label="one" /></option>' .
2027
'<option label="label three" renderer="renderer"><inputType name="name_one" label="one"/></option></config>',
2128
[
22-
"Element 'option': The attribute 'renderer' is required but missing.\nLine: 1\n",
23-
"Element 'option': The attribute " . "'label' is required but missing.\nLine: 1\n",
24-
"Element 'option': The attribute 'name' is required but missing.\nLine: 1\n"
29+
"Element 'option': The attribute 'renderer' is required but missing.\nLine: 1\nThe xml was: \n" .
30+
"0:<?xml version=\"1.0\"?>\n1:<config><option name=\"name_one\" label=\"label one\"><inputType " .
31+
"name=\"name\" label=\"one\"/></option><option name=\"name_two\" renderer=\"renderer\"><inputType " .
32+
"name=\"name_two\" label=\"one\"/></option><option label=\"label three\" renderer=\"renderer\">" .
33+
"<inputType name=\"name_one\" label=\"one\"/></option></config>\n2:\n",
34+
"Element 'option': The attribute 'label' is required but missing.\nLine: 1\nThe xml was: \n" .
35+
"0:<?xml version=\"1.0\"?>\n1:<config><option name=\"name_one\" label=\"label one\"><inputType " .
36+
"name=\"name\" label=\"one\"/></option><option name=\"name_two\" renderer=\"renderer\"><inputType " .
37+
"name=\"name_two\" label=\"one\"/></option><option label=\"label three\" renderer=\"renderer\">" .
38+
"<inputType name=\"name_one\" label=\"one\"/></option></config>\n2:\n",
39+
"Element 'option': The attribute 'name' is required but missing.\nLine: 1\nThe xml was: \n" .
40+
"0:<?xml version=\"1.0\"?>\n1:<config><option name=\"name_one\" label=\"label one\"><inputType " .
41+
"name=\"name\" label=\"one\"/></option><option name=\"name_two\" renderer=\"renderer\"><inputType " .
42+
"name=\"name_two\" label=\"one\"/></option><option label=\"label three\" renderer=\"renderer\">" .
43+
"<inputType name=\"name_one\" label=\"one\"/></option></config>\n2:\n"
2544
],
2645
],
2746
'inputType_node_without_required_attributes' => [
2847
'<?xml version="1.0"?><config><option name="name_one" label="label one" renderer="renderer">' .
2948
'<inputType name="name_one"/></option><option name="name_two" renderer="renderer" label="label">' .
3049
'<inputType label="name_two"/></option></config>',
3150
[
32-
"Element 'inputType': The attribute 'label' is required but missing.\nLine: 1\n",
33-
"Element 'inputType': The " . "attribute 'name' is required but missing.\nLine: 1\n"
51+
"Element 'inputType': The attribute 'label' is required but missing.\nLine: 1\nThe xml was: \n" .
52+
"0:<?xml version=\"1.0\"?>\n1:<config><option name=\"name_one\" label=\"label one\" " .
53+
"renderer=\"renderer\"><inputType name=\"name_one\"/></option><option name=\"name_two\" " .
54+
"renderer=\"renderer\" label=\"label\"><inputType label=\"name_two\"/></option></config>\n2:\n",
55+
"Element 'inputType': The attribute 'name' is required but missing.\nLine: 1\nThe xml was: \n" .
56+
"0:<?xml version=\"1.0\"?>\n1:<config><option name=\"name_one\" label=\"label one\" " .
57+
"renderer=\"renderer\"><inputType name=\"name_one\"/></option><option name=\"name_two\" " .
58+
"renderer=\"renderer\" label=\"label\"><inputType label=\"name_two\"/></option></config>\n2:\n"
3459
],
3560
]
3661
];

app/code/Magento/Catalog/Test/Unit/Model/ProductOptions/Config/_files/invalidProductOptionsXmlArray.php

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,59 @@
88
return [
99
'options_node_is_required' => [
1010
'<?xml version="1.0"?><config><inputType name="name_one" /></config>',
11-
["Element 'inputType': This element is not expected. Expected is ( option ).\nLine: 1\n"],
11+
[
12+
"Element 'inputType': This element is not expected. Expected is ( option ).\nLine: 1\n" .
13+
"The xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><inputType name=\"name_one\"/></config>\n2:\n"
14+
],
1215
],
1316
'inputType_node_is_required' => [
1417
'<?xml version="1.0"?><config><option name="name_one"/></config>',
15-
["Element 'option': Missing child element(s). Expected is ( inputType ).\nLine: 1\n"],
18+
[
19+
"Element 'option': Missing child element(s). Expected is ( inputType ).\nLine: 1\n" .
20+
"The xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><option name=\"name_one\"/></config>\n2:\n"
21+
],
1622
],
1723
'options_name_must_be_unique' => [
1824
'<?xml version="1.0"?><config><option name="name_one"><inputType name="name"/>' .
1925
'</option><option name="name_one"><inputType name="name_two"/></option></config>',
2026
[
21-
"Element 'option': Duplicate key-sequence ['name_one'] in unique identity-constraint " .
22-
"'uniqueOptionName'.\nLine: 1\n"
27+
"Element 'option': Duplicate key-sequence ['name_one'] in unique identity-constraint 'uniqueOptionName'.\n" .
28+
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><option name=\"name_one\">" .
29+
"<inputType name=\"name\"/></option><option name=\"name_one\"><inputType name=\"name_two\"/>" .
30+
"</option></config>\n2:\n"
2331
],
2432
],
2533
'inputType_name_must_be_unique' => [
2634
'<?xml version="1.0"?><config><option name="name"><inputType name="name_one"/>' .
2735
'<inputType name="name_one"/></option></config>',
2836
[
2937
"Element 'inputType': Duplicate key-sequence ['name_one'] in unique identity-constraint " .
30-
"'uniqueInputTypeName'.\nLine: 1\n"
38+
"'uniqueInputTypeName'.\nLine: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n" .
39+
"1:<config><option name=\"name\"><inputType name=\"name_one\"/><inputType name=\"name_one\"/>" .
40+
"</option></config>\n2:\n"
3141
],
3242
],
3343
'renderer_attribute_with_invalid_value' => [
3444
'<?xml version="1.0"?><config><option name="name_one" renderer="123true"><inputType name="name_one"/>' .
3545
'</option></config>',
3646
[
37-
"Element 'option', attribute 'renderer': [facet 'pattern'] The value '123true' is not accepted by the " .
38-
"pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\nLine: 1\n"
47+
"Element 'option', attribute 'renderer': '123true' is not a valid value of the atomic type 'modelName'.\n" .
48+
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><option name=\"name_one\" " .
49+
"renderer=\"123true\"><inputType name=\"name_one\"/></option></config>\n2:\n"
3950
],
4051
],
4152
'disabled_attribute_with_invalid_value' => [
4253
'<?xml version="1.0"?><config><option name="name_one"><inputType name="name_one" disabled="7"/>' .
4354
'<inputType name="name_two" disabled="some_string"/></option></config>',
4455
[
45-
"Element 'inputType', attribute 'disabled': '7' is not a valid value of the atomic type" .
46-
" 'xs:boolean'.\nLine: 1\n",
56+
"Element 'inputType', attribute 'disabled': '7' is not a valid value of the atomic type 'xs:boolean'.\n" .
57+
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><option name=\"name_one\">" .
58+
"<inputType name=\"name_one\" disabled=\"7\"/><inputType name=\"name_two\" disabled=\"some_string\"/>" .
59+
"</option></config>\n2:\n",
4760
"Element 'inputType', attribute 'disabled': 'some_string' is not a valid value of the atomic type " .
48-
"'xs:boolean'.\nLine: 1\n"
61+
"'xs:boolean'.\nLine: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><option name=\"name_one\">" .
62+
"<inputType name=\"name_one\" disabled=\"7\"/><inputType name=\"name_two\" disabled=\"some_string\"/>" .
63+
"</option></config>\n2:\n"
4964
],
5065
]
5166
];

app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/_files/invalidProductTypesMergedXmlArray.php

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,55 @@
99
'type_without_required_name' => [
1010
'<?xml version="1.0" encoding="UTF-8"?><config><type label="some label" modelInstance="model_name" /></config>',
1111
[
12-
"Element 'type': The attribute 'name' is required but missing.\nLine: 1\n",
13-
"Element 'type': Not all fields of key identity-constraint 'productTypeKey' evaluate to a node.\nLine: 1\n"
12+
"Element 'type': The attribute 'name' is required but missing.\nLine: 1\nThe xml was: \n" .
13+
"0:<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n1:<config><type label=\"some label\" " .
14+
"modelInstance=\"model_name\"/></config>\n2:\n",
15+
"Element 'type': Not all fields of key identity-constraint 'productTypeKey' evaluate to a node.\n" .
16+
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n1:<config><type " .
17+
"label=\"some label\" modelInstance=\"model_name\"/></config>\n2:\n"
1418
],
1519
],
1620
'type_without_required_label' => [
1721
'<?xml version="1.0" encoding="UTF-8"?><config><type name="some_name" modelInstance="model_name" /></config>',
18-
["Element 'type': The attribute 'label' is required but missing.\nLine: 1\n"],
22+
[
23+
"Element 'type': The attribute 'label' is required but missing.\nLine: 1\nThe xml was: \n" .
24+
"0:<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n1:<config><type name=\"some_name\" " .
25+
"modelInstance=\"model_name\"/></config>\n2:\n"
26+
],
1927
],
2028
'type_without_required_modelInstance' => [
2129
'<?xml version="1.0" encoding="UTF-8"?><config><type label="some_label" name="some_name" /></config>',
22-
["Element 'type': The attribute 'modelInstance' is required but missing.\nLine: 1\n"],
30+
[
31+
"Element 'type': The attribute 'modelInstance' is required but missing.\nLine: 1\nThe xml was: \n" .
32+
"0:<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n1:<config><type label=\"some_label\" " .
33+
"name=\"some_name\"/></config>\n2:\n"
34+
],
2335
],
2436
'type_pricemodel_without_required_instance_attribute' => [
2537
'<?xml version="1.0" encoding="UTF-8"?><config>' .
2638
'<type label="some_label" name="some_name" modelInstance="model_name"><priceModel/></type></config>',
27-
["Element 'priceModel': The attribute 'instance' is required but missing.\nLine: 1\n"],
39+
[
40+
"Element 'priceModel': The attribute 'instance' is required but missing.\nLine: 1\nThe xml was: \n" .
41+
"0:<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n1:<config><type label=\"some_label\" name=\"some_name\" " .
42+
"modelInstance=\"model_name\"><priceModel/></type></config>\n2:\n"
43+
],
2844
],
2945
'type_indexmodel_without_required_instance_attribute' => [
3046
'<?xml version="1.0" encoding="UTF-8"?><config>' .
3147
'<type label="some_label" name="some_name" modelInstance="model_name"><indexerModel/></type></config>',
32-
["Element 'indexerModel': The attribute 'instance' is required but missing.\nLine: 1\n"],
48+
[
49+
"Element 'indexerModel': The attribute 'instance' is required but missing.\nLine: 1\nThe xml was: \n" .
50+
"0:<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n1:<config><type label=\"some_label\" name=\"some_name\" " .
51+
"modelInstance=\"model_name\"><indexerModel/></type></config>\n2:\n"
52+
],
3353
],
3454
'type_stockindexermodel_without_required_instance_attribute' => [
3555
'<?xml version="1.0" encoding="UTF-8"?><config><type label="some_label" ' .
3656
'name="some_name" modelInstance="model_name"><stockIndexerModel/></type></config>',
37-
["Element 'stockIndexerModel': The attribute 'instance' is required but missing.\nLine: 1\n"],
57+
[
58+
"Element 'stockIndexerModel': The attribute 'instance' is required but missing.\nLine: 1\nThe xml was: \n" .
59+
"0:<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n1:<config><type label=\"some_label\" name=\"some_name\" " .
60+
"modelInstance=\"model_name\"><stockIndexerModel/></type></config>\n2:\n"
61+
],
3862
]
3963
];

0 commit comments

Comments
 (0)