Skip to content

Commit e53dbb6

Browse files
authored
Fix invalid data-sets for unit tests (#95)
* Fix invalid data-sets for catalog unit tests * Fix invalid data-sets for ImportExport unit tests * Fix invalid data-sets for Framework\MessageQueue unit tests * Fix static tests. * Fix invalid data-sets for Sales unit test * Fix invalid data-sets for Integration unit test * Fix invalid data-sets for Email unit test * Fix data providers for unit tests - Config and Directory * Remove totally unnessesary PHP version ifcondition. I tested it on 8.1 8.2 8.3 - all worked good.
1 parent 587dc08 commit e53dbb6

File tree

11 files changed

+62
-49
lines changed

11 files changed

+62
-49
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
'<?xml version="1.0"?><config><option name="name_one" renderer="123true"><inputType name="name_one"/>' .
4545
'</option></config>',
4646
[
47-
"Element 'option', attribute 'renderer': '123true' is not a valid value of the atomic type 'modelName'.\n" .
47+
"Element 'option', attribute 'renderer': [facet 'pattern'] The value '123true' is not accepted " .
48+
"by the pattern '([\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\n" .
4849
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><option name=\"name_one\" " .
4950
"renderer=\"123true\"><inputType name=\"name_one\"/></option></config>\n2:\n"
5051
],

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
'type_modelinstance_invalid_value' => [
3333
'<?xml version="1.0"?><config><type name="some_name" modelInstance="123" /></config>',
3434
[
35-
"Element 'type', attribute 'modelInstance': '123' is not a valid value of the atomic type 'modelName'.\n" .
35+
"Element 'type', attribute 'modelInstance': [facet 'pattern'] The value '123' is not " .
36+
"accepted by the pattern '([\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\n" .
3637
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><type name=\"some_name\" " .
3738
"modelInstance=\"123\"/></config>\n2:\n"
3839
],
@@ -71,16 +72,18 @@
7172
'type_pricemodel_instance_invalid_value' => [
7273
'<?xml version="1.0"?><config><type name="some_name"><priceModel instance="123123" /></type></config>',
7374
[
74-
"Element 'priceModel', attribute 'instance': '123123' is not a valid value of the atomic " .
75-
"type 'modelName'.\nLine: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><type " .
75+
"Element 'priceModel', attribute 'instance': [facet 'pattern'] The value '123123' is not accepted " .
76+
"by the pattern '([\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\n" .
77+
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><type " .
7678
"name=\"some_name\"><priceModel instance=\"123123\"/></type></config>\n2:\n"
7779
],
7880
],
7981
'type_indexermodel_instance_invalid_value' => [
8082
'<?xml version="1.0"?><config><type name="some_name"><indexerModel instance="123" /></type></config>',
8183
[
82-
"Element 'indexerModel', attribute 'instance': '123' is not a valid value of the atomic type " .
83-
"'modelName'.\nLine: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><type " .
84+
"Element 'indexerModel', attribute 'instance': [facet 'pattern'] The value '123' is not accepted " .
85+
"by the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\n" .
86+
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><type " .
8487
"name=\"some_name\"><indexerModel instance=\"123\"/></type></config>\n2:\n"
8588
],
8689
],
@@ -102,8 +105,9 @@
102105
'stockindexermodel_instance_invalid_value' => [
103106
'<?xml version="1.0"?><config><type name="some_name"><stockIndexerModel instance="1234"/></type></config>',
104107
[
105-
"Element 'stockIndexerModel', attribute 'instance': '1234' is not a valid value of the atomic type " .
106-
"'modelName'.\nLine: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><type " .
108+
"Element 'stockIndexerModel', attribute 'instance': [facet 'pattern'] The value '1234' is not accepted " .
109+
"by the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\n" .
110+
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><type " .
107111
"name=\"some_name\"><stockIndexerModel instance=\"1234\"/></type></config>\n2:\n"
108112
],
109113
],

app/code/Magento/Config/Test/Unit/Model/Config/_files/invalidSystemXmlArray.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@
9090
"1:<config><system><section id=\"section1\"><group id=\"group1\"><label>Label</label><field " .
9191
"id=\"field_id\"><config_path>co</config_path></field></group><group id=\"group2\"><label>" .
9292
"Label_One</label></group></section></system></config>\n2:\n",
93-
"Element 'config_path': 'co' is not a valid value of the atomic type 'typeConfigPath'.\nLine: 1\n" .
93+
"Element 'config_path': [facet 'minLength'] The value has a length of '2'; " .
94+
"this underruns the allowed minimum length of '5'.\nLine: 1\n" .
9495
"The xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><system><section id=\"section1\"><group " .
9596
"id=\"group1\"><label>Label</label><field id=\"field_id\"><config_path>co</config_path></field>" .
9697
"</group><group id=\"group2\"><label>Label_One</label></group></section></system></config>\n2:\n"
@@ -107,7 +108,8 @@
107108
"1:<config><system><section id=\"section1\"><group id=\"group1\"><label>Label</label><field " .
108109
"id=\"field_id\"><if_module_enabled>Som</if_module_enabled></field></group><group id=\"group2\">" .
109110
"<label>Label_One</label></group></section></system></config>\n2:\n",
110-
"Element 'if_module_enabled': 'Som' is not a valid value of the atomic type 'typeModule'.\n" .
111+
"Element 'if_module_enabled': [facet 'minLength'] The value has a length of '3'; " .
112+
"this underruns the allowed minimum length of '5'.\n" .
111113
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><system><section id=\"section1\">" .
112114
"<group id=\"group1\"><label>Label</label><field id=\"field_id\"><if_module_enabled>Som" .
113115
"</if_module_enabled></field></group><group id=\"group2\"><label>Label_One</label></group>" .

app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,12 @@ function (array $args) {
138138
*/
139139
public function getOutputFormatDataProvider(): array
140140
{
141-
$ar_DZ = "\u{062C}.\u{0645}.\u{200F}\u{00A0}%s";
142-
if (version_compare(PHP_VERSION, '8.3', '>=')) {
143-
$ar_DZ = "%s\u{00A0}\u{062C}.\u{0645}.\u{200F}";
144-
}
145141
return [
146142
'en_US:USD' => ['en_US', 'USD', '$%s'],
147143
'en_US:PLN' => ['en_US', 'PLN', "PLN\u{00A0}%s"],
148144
'en_US:PKR' => ['en_US', 'PKR', "PKR\u{00A0}%s"],
149145
'af_ZA:VND' => ['af_ZA', 'VND', "\u{20AB}%s"],
150-
'ar_DZ:EGP' => ['ar_DZ', 'EGP', $ar_DZ],
146+
'ar_DZ:EGP' => ['ar_DZ', 'EGP', "%s\u{00A0}\u{062C}.\u{0645}.\u{200F}"],
151147
'ar_SA:USD' => ['ar_SA', 'USD', "%s\u{00A0}US$"],
152148
'ar_SA:LBP' => ['ar_SA', 'LBP', "%s\u{00A0}\u{0644}.\u{0644}.\u{200F}"],
153149
'fa_IR:USD' => ['fa_IR', 'USD', "\u{200E}$%s"],

app/code/Magento/Email/Test/Unit/Model/Template/Config/XsdTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ public function mergedXmlDataProvider()
143143
'node "template" with invalid attribute "area"' => [
144144
'<config><template id="test" label="Test" file="test.txt" type="text" module="Module" area="invalid"/></config>',
145145
[
146-
"Element 'template', attribute 'area': 'invalid' is not a valid value of the atomic type " .
147-
"'areaType'.The xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><template id=\"test\" " .
146+
"Element 'template', attribute 'area': [facet 'enumeration'] The value 'invalid' is not " .
147+
"an element of the set {'frontend', 'adminhtml'}.The xml was: \n" .
148+
"0:<?xml version=\"1.0\"?>\n1:<config><template id=\"test\" " .
148149
"label=\"Test\" file=\"test.txt\" type=\"text\" module=\"Module\" area=\"invalid\"/>" .
149150
"</config>\n2:\n",
150151
],

app/code/Magento/ImportExport/Test/Unit/Model/Export/Config/_files/invalidExportXmlArray.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,14 @@
2626
],
2727
'attributes_with_type_modelName_and_invalid_value' => [
2828
'<?xml version="1.0"?><config><entity name="Name/one" model="model_one" '
29-
. 'entityAttributeFilterType="model_one"/><entityType entity="Name/one" name="name_one" model="1"/>'
30-
. ' <fileFormat name="name_one" model="1model"/></config>',
29+
. 'entityAttributeFilterType="model_one"/><entityType entity="Name/one" name="name_one" model="1"/>'
30+
. ' <fileFormat name="name_one" model="1model"/></config>',
3131
[
32-
"Element 'entityType', attribute 'model': '1' is not a valid value of the atomic type 'modelName'.\n" .
33-
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><entity name=\"Name/one\" " .
34-
"model=\"model_one\" entityAttributeFilterType=\"model_one\"/><entityType entity=\"Name/one\" " .
35-
"name=\"name_one\" model=\"1\"/> <fileFormat name=\"name_one\" model=\"1model\"/></config>\n2:\n",
36-
"Element 'fileFormat', attribute 'model': '1model' is not a valid value of the atomic type 'modelName'.\n" .
37-
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><entity name=\"Name/one\" " .
38-
"model=\"model_one\" entityAttributeFilterType=\"model_one\"/><entityType entity=\"Name/one\" " .
39-
"name=\"name_one\" model=\"1\"/> <fileFormat name=\"name_one\" model=\"1model\"/></config>\n2:\n"
32+
"Element 'fileFormat', attribute 'model': [facet 'pattern'] The value '1model'" .
33+
" is not accepted by the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\n" .
34+
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><entity name=\"Name/one\"" .
35+
" model=\"model_one\" entityAttributeFilterType=\"model_one\"/><entityType entity=\"Name/one\"" .
36+
" name=\"name_one\" model=\"1\"/> <fileFormat name=\"name_one\" model=\"1model\"/></config>\n2:\n"
4037
],
4138
],
4239
'productType_node_with_required_attribute' => [

app/code/Magento/ImportExport/Test/Unit/Model/Import/Config/_files/invalidImportMergedXmlArray.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
'<?xml version="1.0"?><config><entity name="test_name" label="test_label" model="34afwer" ' .
5252
'behaviorModel="test" /></config>',
5353
[
54-
"Element 'entity', attribute 'model': '34afwer' is not a valid value of the atomic type 'modelName'.\n" .
54+
"Element 'entity', attribute 'model': [facet 'pattern'] The value '34afwer'" .
55+
" is not accepted by the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\n" .
5556
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><entity name=\"test_name\" " .
5657
"label=\"test_label\" model=\"34afwer\" behaviorModel=\"test\"/></config>\n2:\n"
5758
],
@@ -60,8 +61,9 @@
6061
'<?xml version="1.0"?><config><entity name="test_name" label="test_label" model="test" behaviorModel="666" />' .
6162
'</config>',
6263
[
63-
"Element 'entity', attribute 'behaviorModel': '666' is not a valid value of the atomic type " .
64-
"'modelName'.\nLine: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><entity " .
64+
"Element 'entity', attribute 'behaviorModel': [facet 'pattern'] The value '666'" .
65+
" is not accepted by the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\n" .
66+
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><entity " .
6567
"name=\"test_name\" label=\"test_label\" model=\"test\" behaviorModel=\"666\"/></config>\n2:\n"
6668
],
6769
]

app/code/Magento/ImportExport/Test/Unit/Model/Import/Config/_files/invalidImportXmlArray.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,18 @@
2424
'entity_with_invalid_model_value' => [
2525
'<?xml version="1.0"?><config><entity name="some_name" model="12345"/></config>',
2626
[
27-
"Element 'entity', attribute 'model': '12345' is not a valid value of the atomic type 'modelName'.\n" .
28-
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><entity name=\"some_name\" " .
29-
"model=\"12345\"/></config>\n2:\n"
30-
27+
"Element 'entity', attribute 'model': [facet 'pattern'] The value '12345' is not accepted " .
28+
"by the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\n" .
29+
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><entity name=\"some_name\"" .
30+
" model=\"12345\"/></config>\n2:\n"
3131
],
3232
],
3333
'entity_with_invalid_behaviormodel_value' => [
3434
'<?xml version="1.0"?><config><entity name="some_name" behaviorModel="=--09"/></config>',
3535
[
36-
"Element 'entity', attribute 'behaviorModel': '=--09' is not a valid value of the atomic type " .
37-
"'modelName'.\nLine: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><entity " .
36+
"Element 'entity', attribute 'behaviorModel': [facet 'pattern'] The value '=--09'" .
37+
" is not accepted by the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\n" .
38+
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><entity " .
3839
"name=\"some_name\" behaviorModel=\"=--09\"/></config>\n2:\n"
3940
],
4041
],
@@ -65,7 +66,8 @@
6566
'entitytype_with_invalid_model_attribute_value' => [
6667
'<?xml version="1.0"?><config><entityType entity="entity_name" name="some_name" model="1test"/></config>',
6768
[
68-
"Element 'entityType', attribute 'model': '1test' is not a valid value of the atomic type 'modelName'.\n" .
69+
"Element 'entityType', attribute 'model': [facet 'pattern'] The value '1test'" .
70+
" is not accepted by the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\n" .
6971
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n" .
7072
"1:<config><entityType entity=\"entity_name\" name=\"some_name\" model=\"1test\"/></config>\n2:\n"
7173
],

app/code/Magento/Integration/Test/Unit/Model/Config/XsdTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,9 @@ public function exemplarXmlDataProvider()
349349
</integration>
350350
</integrations>',
351351
[
352-
"Element 'integration', attribute 'name': '' is not a valid value of the atomic type " .
353-
"'integrationNameType'.The xml was: \n0:<?xml version=\"1.0\"?>\n1:<integrations>\n" .
352+
"Element 'integration', attribute 'name': [facet 'minLength'] The value '' has a " .
353+
"length of '0'; this underruns the allowed minimum length of '2'.The xml was: \n" .
354+
"0:<?xml version=\"1.0\"?>\n1:<integrations>\n" .
354355
"2: <integration name=\"\">\n3: <email>" .
355356
"test-integration1@magento.com</email>\n4: <endpoint_url>" .
356357
"http://endpoint.url</endpoint_url>\n5: <identity_link_url>" .
@@ -368,7 +369,8 @@ public function exemplarXmlDataProvider()
368369
</integration>
369370
</integrations>',
370371
[
371-
"Element 'email': 'invalid' is not a valid value of the atomic type 'emailType'.The xml was: \n" .
372+
"Element 'email': [facet 'pattern'] The value 'invalid' is not accepted by " .
373+
"the pattern '[^@]+@[^\.]+\..+'.The xml was: \n" .
372374
"0:<?xml version=\"1.0\"?>\n1:<integrations>\n2: <integration " .
373375
"name=\"TestIntegration1\">\n3: <email>invalid</email>\n" .
374376
"4: <endpoint_url>http://endpoint.url</endpoint_url>\n" .

app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/XsdTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ protected function _getExemplarTestData()
188188
'non-valid empty renderer class name' => [
189189
'<config><renderers><page type="p1"><renderer product_type="prt1"/></page></renderers></config>',
190190
[
191-
"Element 'renderer': '' is not a valid value of the atomic type 'classNameType'.The xml was: \n" .
191+
"Element 'renderer': [facet 'pattern'] The value '' is not accepted by the pattern " .
192+
"'[A-Z][a-zA-Z\d]*(\\\\[A-Z][a-zA-Z\d]*)*'.The xml was: \n" .
192193
"0:<?xml version=\"1.0\"?>\n1:<config><renderers><page type=\"p1\"><renderer " .
193194
"product_type=\"prt1\"/></page></renderers></config>\n2:\n"
194195
],
@@ -256,8 +257,9 @@ protected function _getExemplarTestData()
256257
'<config><totals><total name="i1"><title>Title</title><source_field>foo</source_field>' .
257258
'<model>a model</model></total></totals></config>',
258259
[
259-
"Element 'model': 'a model' is not a valid value of the atomic type 'classNameType'.The xml " .
260-
"was: \n0:<?xml version=\"1.0\"?>\n1:<config><totals><total name=\"i1\"><title>Title</title>" .
260+
"Element 'model': [facet 'pattern'] The value 'a model' is not accepted by the pattern " .
261+
"'[A-Z][a-zA-Z\d]*(\\\\[A-Z][a-zA-Z\d]*)*'.The xml was: \n" .
262+
"0:<?xml version=\"1.0\"?>\n1:<config><totals><total name=\"i1\"><title>Title</title>" .
261263
"<source_field>foo</source_field><model>a model</model></total></totals></config>\n2:\n"
262264
],
263265
],

0 commit comments

Comments
 (0)