Skip to content

Commit f52fd9d

Browse files
committed
Merge branch '2.4-develop' into ACP2E-3456
2 parents 2f8eb43 + 1984c61 commit f52fd9d

File tree

26 files changed

+964
-164
lines changed

26 files changed

+964
-164
lines changed

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2013 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -38,24 +38,33 @@ protected function setUp(): void
3838
* @param string $schemaName
3939
* @param string $xmlString
4040
* @param array $expectedError
41+
* @param bool $isRegex
4142
*/
42-
protected function _loadDataForTest($schemaName, $xmlString, $expectedError)
43+
protected function _loadDataForTest($schemaName, $xmlString, $expectedError, $isRegex = false)
4344
{
44-
$actualError = $this->_xsdValidator->validate($this->_xsdSchemaPath . $schemaName, $xmlString);
45-
$this->assertEquals(false, empty($actualError));
45+
$actualErrors = $this->_xsdValidator->validate($this->_xsdSchemaPath . $schemaName, $xmlString);
46+
$this->assertNotEmpty($actualErrors);
47+
4648
foreach ($expectedError as $error) {
47-
$this->assertContains($error, $actualError);
49+
if ($isRegex) {
50+
foreach ($actualErrors as $actualError) {
51+
$this->assertMatchesRegularExpression($error, $actualError);
52+
}
53+
} else {
54+
$this->assertContains($error, $actualErrors);
55+
}
4856
}
4957
}
5058

5159
/**
5260
* @param string $xmlString
5361
* @param array $expectedError
62+
* @param $isRegex
5463
* @dataProvider schemaCorrectlyIdentifiesInvalidProductOptionsDataProvider
5564
*/
56-
public function testSchemaCorrectlyIdentifiesInvalidProductOptionsXml($xmlString, $expectedError)
65+
public function testSchemaCorrectlyIdentifiesInvalidProductOptionsXml($xmlString, $expectedError, $isRegex)
5766
{
58-
$this->_loadDataForTest('product_options.xsd', $xmlString, $expectedError);
67+
$this->_loadDataForTest('product_options.xsd', $xmlString, $expectedError, $isRegex);
5968
}
6069

6170
/**

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2013 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -12,13 +12,15 @@
1212
"Element 'inputType': This element is not expected. Expected is ( option ).\nLine: 1\n" .
1313
"The xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><inputType name=\"name_one\"/></config>\n2:\n"
1414
],
15+
'isRegex' => false
1516
],
1617
'inputType_node_is_required' => [
1718
'<?xml version="1.0"?><config><option name="name_one"/></config>',
1819
[
1920
"Element 'option': Missing child element(s). Expected is ( inputType ).\nLine: 1\n" .
2021
"The xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><option name=\"name_one\"/></config>\n2:\n"
2122
],
23+
'isRegex' => false
2224
],
2325
'options_name_must_be_unique' => [
2426
'<?xml version="1.0"?><config><option name="name_one"><inputType name="name"/>' .
@@ -29,6 +31,7 @@
2931
"name=\"name_one\"><inputType name=\"name\"/></option><option name=\"name_one\"><inputType " .
3032
"name=\"name_two\"/></option></config>\n2:\n"
3133
],
34+
'isRegex' => false
3235
],
3336
'inputType_name_must_be_unique' => [
3437
'<?xml version="1.0"?><config><option name="name"><inputType name="name_one"/>' .
@@ -39,15 +42,15 @@
3942
"1:<config><option name=\"name\"><inputType name=\"name_one\"/><inputType name=\"name_one\"/>" .
4043
"</option></config>\n2:\n"
4144
],
45+
'isRegex' => false
4246
],
4347
'renderer_attribute_with_invalid_value' => [
4448
'<?xml version="1.0"?><config><option name="name_one" renderer="123true"><inputType name="name_one"/>' .
4549
'</option></config>',
4650
[
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"
51+
"/Element \'option\', attribute \'renderer\': .* (is not a valid value|is not accepted).*/"
5052
],
53+
'isRegex' => true
5154
],
5255
'disabled_attribute_with_invalid_value' => [
5356
'<?xml version="1.0"?><config><option name="name_one"><inputType name="name_one" disabled="7"/>' .
@@ -62,5 +65,6 @@
6265
"<inputType name=\"name_one\" disabled=\"7\"/><inputType name=\"name_two\" disabled=\"some_string\"/>" .
6366
"</option></config>\n2:\n"
6467
],
68+
'isRegex' => false
6569
]
6670
];

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2013 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -37,14 +37,22 @@ protected function setUp(): void
3737
/**
3838
* @param string $xmlString
3939
* @param array $expectedError
40+
* @param bool $isRegex
4041
* @dataProvider schemaCorrectlyIdentifiesInvalidXmlDataProvider
4142
*/
42-
public function testSchemaCorrectlyIdentifiesInvalidXml($xmlString, $expectedError)
43+
public function testSchemaCorrectlyIdentifiesInvalidXml($xmlString, $expectedError, $isRegex = false)
4344
{
44-
$actualError = $this->_xsdValidator->validate($this->_xsdSchema, $xmlString);
45-
$this->assertEquals(false, empty($actualError));
45+
$actualErrors = $this->_xsdValidator->validate($this->_xsdSchema, $xmlString);
46+
$this->assertEquals(false, empty($actualErrors));
47+
4648
foreach ($expectedError as $error) {
47-
$this->assertContains($error, $actualError);
49+
if ($isRegex) {
50+
foreach ($actualErrors as $actualError) {
51+
$this->assertMatchesRegularExpression($error, $actualError);
52+
}
53+
} else {
54+
$this->assertContains($error, $actualErrors);
55+
}
4856
}
4957
}
5058

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

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2013 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -13,13 +13,15 @@
1313
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><type name=\"some_name\"/><type " .
1414
"name=\"some_name\"/></config>\n2:\n"
1515
],
16+
'isRegex' => false
1617
],
1718
'type_without_required_name_attribute' => [
1819
'<?xml version="1.0"?><config><type /></config>',
1920
[
2021
"Element 'type': The attribute 'name' is required but missing.\n" .
2122
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><type/></config>\n2:\n"
2223
],
24+
'isRegex' => false
2325
],
2426
'type_with_notallowed_attribute' => [
2527
'<?xml version="1.0"?><config><type name="some_name" notallowed="text"/></config>',
@@ -28,14 +30,14 @@
2830
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><type name=\"some_name\" " .
2931
"notallowed=\"text\"/></config>\n2:\n"
3032
],
33+
'isRegex' => false
3134
],
3235
'type_modelinstance_invalid_value' => [
3336
'<?xml version="1.0"?><config><type name="some_name" modelInstance="123" /></config>',
3437
[
35-
"Element 'type', attribute 'modelInstance': '123' is not a valid value of the atomic type 'modelName'.\n" .
36-
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><type name=\"some_name\" " .
37-
"modelInstance=\"123\"/></config>\n2:\n"
38+
"/Element \'type\', attribute \'modelInstance\': .* (is not a valid value|is not accepted).*/"
3839
],
40+
'isRegex' => true
3941
],
4042
'type_indexpriority_invalid_value' => [
4143
'<?xml version="1.0"?><config><type name="some_name" indexPriority="-1" /></config>',
@@ -44,6 +46,7 @@
4446
"'xs:nonNegativeInteger'.\nLine: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n" .
4547
"1:<config><type name=\"some_name\" indexPriority=\"-1\"/></config>\n2:\n"
4648
],
49+
'isRegex' => false
4750
],
4851
'type_canuseqtydecimals_invalid_value' => [
4952
'<?xml version="1.0"?><config><type name="some_name" canUseQtyDecimals="string" /></config>',
@@ -52,6 +55,7 @@
5255
"'xs:boolean'.\nLine: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n" .
5356
"1:<config><type name=\"some_name\" canUseQtyDecimals=\"string\"/></config>\n2:\n"
5457
],
58+
'isRegex' => false
5559
],
5660
'type_isqty_invalid_value' => [
5761
'<?xml version="1.0"?><config><type name="some_name" isQty="string" /></config>',
@@ -60,36 +64,37 @@
6064
"\nLine: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><type name=\"some_name\" " .
6165
"isQty=\"string\"/></config>\n2:\n"
6266
],
67+
'isRegex' => false
6368
],
6469
'type_pricemodel_without_required_instance_attribute' => [
6570
'<?xml version="1.0"?><config><type name="some_name"><priceModel /></type></config>',
6671
[
6772
"Element 'priceModel': The attribute 'instance' is required but missing.\nLine: 1\nThe xml was: \n" .
6873
"0:<?xml version=\"1.0\"?>\n1:<config><type name=\"some_name\"><priceModel/></type></config>\n2:\n"
6974
],
75+
'isRegex' => false
7076
],
7177
'type_pricemodel_instance_invalid_value' => [
7278
'<?xml version="1.0"?><config><type name="some_name"><priceModel instance="123123" /></type></config>',
7379
[
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 " .
76-
"name=\"some_name\"><priceModel instance=\"123123\"/></type></config>\n2:\n"
80+
"/Element \'priceModel\', attribute \'instance\': .* (is not a valid value|is not accepted).*/"
7781
],
82+
'isRegex' => true
7883
],
7984
'type_indexermodel_instance_invalid_value' => [
8085
'<?xml version="1.0"?><config><type name="some_name"><indexerModel instance="123" /></type></config>',
8186
[
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-
"name=\"some_name\"><indexerModel instance=\"123\"/></type></config>\n2:\n"
87+
"/Element \'indexerModel\', attribute \'instance\': .* (is not a valid value|is not accepted).*/"
8588
],
89+
'isRegex' => true
8690
],
8791
'type_indexermodel_without_required_instance_attribute' => [
8892
'<?xml version="1.0"?><config><type name="some_name"><indexerModel /></type></config>',
8993
[
9094
"Element 'indexerModel': The attribute 'instance' is required but missing.\nLine: 1\nThe xml was: \n" .
9195
"0:<?xml version=\"1.0\"?>\n1:<config><type name=\"some_name\"><indexerModel/></type></config>\n2:\n"
9296
],
97+
'isRegex' => false
9398
],
9499
'stockindexermodel_without_required_instance_attribute' => [
95100
'<?xml version="1.0"?><config><type name="some_name"><stockIndexerModel /></type></config>',
@@ -98,14 +103,14 @@
98103
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n" .
99104
"1:<config><type name=\"some_name\"><stockIndexerModel/></type></config>\n2:\n"
100105
],
106+
'isRegex' => false
101107
],
102108
'stockindexermodel_instance_invalid_value' => [
103109
'<?xml version="1.0"?><config><type name="some_name"><stockIndexerModel instance="1234"/></type></config>',
104110
[
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 " .
107-
"name=\"some_name\"><stockIndexerModel instance=\"1234\"/></type></config>\n2:\n"
111+
"/Element \'stockIndexerModel\', attribute \'instance\': .* (is not a valid value|is not accepted).*/"
108112
],
113+
'isRegex' => true
109114
],
110115
'allowedselectiontypes_without_required_type_handle' => [
111116
'<?xml version="1.0"?><config><type name="some_name"><allowedSelectionTypes /></type></config>',
@@ -114,6 +119,7 @@
114119
"Line: 1\nThe xml was: \n0:<?xml version=\"1.0\"?>\n1:<config><type name=\"some_name\">" .
115120
"<allowedSelectionTypes/></type></config>\n2:\n"
116121
],
122+
'isRegex' => false
117123
],
118124
'allowedselectiontypes_type_without_required_name' => [
119125
'<?xml version="1.0"?><config><type name="some_name"><allowedSelectionTypes><type/></allowedSelectionTypes>"
@@ -127,5 +133,6 @@
127133
"1:<config><type name=\"some_name\"><allowedSelectionTypes><type/>" .
128134
"</allowedSelectionTypes>\"\n2: . \"</type></config>\n3:\n"
129135
],
136+
'isRegex' => false
130137
]
131138
];

0 commit comments

Comments
 (0)