Skip to content

Commit 7957051

Browse files
author
Maksym Aposov
committed
MAGETWO-37581: Update XSD declaration
1 parent dc048a4 commit 7957051

File tree

4 files changed

+230
-1
lines changed

4 files changed

+230
-1
lines changed

app/code/Magento/Indexer/etc/indexer.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
<xs:complexContent>
123123
<xs:extension base="fieldTypeAbstract">
124124
<xs:sequence>
125-
<xs:element type="filterType" name="filter" minOccurs="1" maxOccurs="1" />
125+
<xs:element type="filterType" name="filter" minOccurs="0" maxOccurs="1" />
126126
</xs:sequence>
127127
</xs:extension>
128128
</xs:complexContent>
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<?php
2+
/**
3+
* Test indexer.xsd and xml files.
4+
*
5+
* Find "indexer.xml" files in code tree and validate them. Also verify schema fails on an invalid xml and
6+
* passes on a valid xml.
7+
*
8+
* Copyright © 2015 Magento. All rights reserved.
9+
* See COPYING.txt for license details.
10+
*/
11+
namespace Magento\Test\Integrity\Magento\Indexer;
12+
13+
class ConfigTest extends \Magento\TestFramework\Integrity\AbstractConfig
14+
{
15+
/**
16+
* Returns the name of the XSD file to be used to validate the XML
17+
*
18+
* @return string
19+
*/
20+
protected function _getXsd()
21+
{
22+
return '/app/code/Magento/Indexer/etc/indexer.xsd';
23+
}
24+
25+
/**
26+
* The location of a single valid complete xml file
27+
*
28+
* @return string
29+
*/
30+
protected function _getKnownValidXml()
31+
{
32+
return __DIR__ . '/_files/valid_indexer.xml';
33+
}
34+
35+
/**
36+
* The location of a single known invalid complete xml file
37+
*
38+
* @return string
39+
*/
40+
protected function _getKnownInvalidXml()
41+
{
42+
return __DIR__ . '/_files/invalid_indexer.xml';
43+
}
44+
45+
/**
46+
* The location of a single known valid partial xml file
47+
*
48+
* @return string
49+
*/
50+
protected function _getKnownValidPartialXml()
51+
{
52+
return '';
53+
}
54+
55+
/**
56+
* Returns the name of the XSD file to be used to validate partial XML
57+
*
58+
* @return string
59+
*/
60+
protected function _getFileXsd()
61+
{
62+
return '';
63+
}
64+
65+
/**
66+
* The location of a single known invalid partial xml file
67+
*
68+
* @return string
69+
*/
70+
protected function _getKnownInvalidPartialXml()
71+
{
72+
return '';
73+
}
74+
75+
/**
76+
* Returns the name of the xml files to validate
77+
*
78+
* @return string
79+
*/
80+
protected function _getXmlName()
81+
{
82+
return 'indexer.xml';
83+
}
84+
85+
public function testFileSchemaUsingInvalidXml($expectedErrors = null)
86+
{
87+
$this->markTestSkipped('indexer.xml does not have a partial schema');
88+
}
89+
90+
public function testSchemaUsingPartialXml($expectedErrors = null)
91+
{
92+
$this->markTestSkipped('indexer.xml does not have a partial schema');
93+
}
94+
95+
public function testFileSchemaUsingPartialXml()
96+
{
97+
$this->markTestSkipped('indexer.xml does not have a partial schema');
98+
}
99+
100+
public function testSchemaUsingInvalidXml($expectedErrors = null)
101+
{
102+
$expectedErrors = array_filter(
103+
explode(
104+
"\n",
105+
"
106+
Element 'indexer': Duplicate key-sequence ['catalogsearch_fulltext'] in unique identity-constraint 'uniqueViewId'.
107+
Element 'indexer': Duplicate key-sequence ['indexer_0', 'catalogsearch_fulltext'] in unique identity-constraint" .
108+
" 'uniqueIndexertId'.
109+
Element 'fields': Missing child element(s). Expected is ( field ).
110+
Element 'fields', attribute 'handler': [facet 'pattern'] The value 'field_handler' is not accepted" .
111+
" by the pattern '[a-zA-Z\\\\]+'.
112+
Element 'fields', attribute 'handler': 'field_handler' is not a valid value of the atomic type 'classType'.
113+
Element 'field': Duplicate key-sequence ['visibility'] in unique identity-constraint 'uniqueField'.
114+
Element 'field', attribute 'origin': [facet 'pattern'] The value 'table_name_field_name' is not accepted" .
115+
" by the pattern '[a-zA-Z0-9_]+\\.[a-zA-Z0-9_]+'.
116+
Element 'field', attribute 'origin': 'table_name_field_name' is not a valid value of the atomic type 'originType'.
117+
Element 'field': The attribute 'dataType' is required but missing.
118+
Element 'field', attribute '{http://www.w3.org/2001/XMLSchema-instance}type': The QName value 'any'" .
119+
" of the xsi:type attribute does not resolve to a type definition.
120+
Element 'field', attribute 'dataType': [facet 'enumeration'] The value 'string' is not an element" .
121+
" of the set {'int', 'float', 'varchar'}.
122+
Element 'field', attribute 'dataType': 'string' is not a valid value of the atomic type 'dataType'."
123+
)
124+
);
125+
parent::testSchemaUsingInvalidXml($expectedErrors);
126+
}
127+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* This file contains errors that will fail schema validation.
5+
*
6+
* Copyright © 2015 Magento. All rights reserved.
7+
* See COPYING.txt for license details.
8+
*/
9+
-->
10+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../app/code/Magento/Indexer/etc/indexer.xsd">
11+
<indexer id="indexer_0" view_id="catalogsearch_fulltext" class="NotAClass">
12+
<title translate="true">Test Indexer Declaration</title>
13+
<description translate="true">Invalid class attribute value</description>
14+
</indexer>
15+
<indexer id="indexer_0" view_id="catalogsearch_fulltext" class="Magento\CatalogSearch\Model\Indexer\Fulltext">
16+
<title translate="true">Test Indexer Declaration</title>
17+
<description translate="true">Duplicate indexer id</description>
18+
</indexer>
19+
<indexer id="indexer_10" view_id="catalogsearch_fulltext_10" class="Magento\CatalogSearch\Model\Indexer\Fulltext">
20+
<title translate="true">Test Indexer Declaration</title>
21+
<description translate="true">Duplicate 'view_id' in indexer declaration</description>
22+
</indexer>
23+
<indexer id="indexer_11" view_id="catalogsearch_fulltext_11" class="Magento\CatalogSearch\Model\Indexer\Fulltext">
24+
<title translate="true">Test Indexer Declaration</title>
25+
<description translate="true">Empty fields</description>
26+
<fields handler="Magento\Framework\Search\Index\Fields\Handler"/>
27+
</indexer>
28+
<indexer id="indexer_1" view_id="catalogsearch_fulltext_1" class="Magento\CatalogSearch\Model\Indexer\Fulltext">
29+
<title translate="true">Test Indexer Declaration</title>
30+
<description translate="true">Invalid handler attribute value</description>
31+
<fields handler="field_handler">
32+
<field name="visibility" origin="table_name.field_name" handler="Magento\Framework\Search\Index\Field\Handler\Class" xsi:type="filter" dataType="int" />
33+
</fields>
34+
</indexer>
35+
<indexer id="indexer_2" view_id="catalogsearch_fulltext_2" class="Magento\CatalogSearch\Model\Indexer\Fulltext">
36+
<title translate="true">Test Indexer Declaration</title>
37+
<description translate="true">Duplicate field declaration</description>
38+
<fields handler="Magento\Framework\Search\Index\Fields\Handler">
39+
<field name="visibility" origin="table_name.field_name" handler="Magento\Framework\Search\Index\Field\Handler\Class" xsi:type="filter" dataType="int" />
40+
<field name="visibility" origin="table_name.field_name" handler="Magento\Framework\Search\Index\Field\Handler\Class" xsi:type="both">
41+
<filter class="Magento\Framework\Search\Index\Filter\StopWordsFilter"/>
42+
</field>
43+
</fields>
44+
</indexer>
45+
<indexer id="indexer_3" view_id="catalogsearch_fulltext_3" class="Magento\CatalogSearch\Model\Indexer\Fulltext">
46+
<title translate="true">Test Indexer Declaration</title>
47+
<description translate="true">Invalid origin attribute value</description>
48+
<fields handler="Magento\Framework\Search\Index\Fields\Handler">
49+
<field name="visibility" origin="table_name_field_name" handler="Magento\Framework\Search\Index\Field\Handler\Class" xsi:type="both"/>
50+
</fields>
51+
</indexer>
52+
<indexer id="indexer_4" view_id="catalogsearch_fulltext_4" class="Magento\CatalogSearch\Model\Indexer\Fulltext">
53+
<title translate="true">Test Indexer Declaration</title>
54+
<description translate="true">Invalid field handler attribute value</description>
55+
<fields handler="Magento\Framework\Search\Index\Fields\Handler">
56+
<field name="visibility" origin="table_name.field_name" handler="handler" xsi:type="filter" dataType="int"/>
57+
</fields>
58+
</indexer>
59+
<indexer id="indexer_5" view_id="catalogsearch_fulltext_5" class="Magento\CatalogSearch\Model\Indexer\Fulltext">
60+
<title translate="true">Test Indexer Declaration</title>
61+
<description translate="true">Invalid field type</description>
62+
<fields handler="Magento\Framework\Search\Index\Fields\Handler">
63+
<field name="visibility" origin="table_name.field_name" handler="Magento\Framework\Search\Index\Field\Handler\Class" xsi:type="any"/>
64+
</fields>
65+
</indexer>
66+
<indexer id="indexer_6" view_id="catalogsearch_fulltext_6" class="Magento\CatalogSearch\Model\Indexer\Fulltext">
67+
<title translate="true">Test Indexer Declaration</title>
68+
<description translate="true">No dataType attribute for 'filter' type field</description>
69+
<fields handler="Magento\Framework\Search\Index\Fields\Handler">
70+
<field name="visibility" origin="table_name.field_name" handler="Magento\Framework\Search\Index\Field\Handler\Class" xsi:type="filter"/>
71+
</fields>
72+
</indexer>
73+
<indexer id="indexer_12" view_id="catalogsearch_fulltext_12" class="Magento\CatalogSearch\Model\Indexer\Fulltext">
74+
<title translate="true">Test Indexer Declaration</title>
75+
<description translate="true">Invalid field dataType attribute value</description>
76+
<fields handler="Magento\Framework\Search\Index\Fields\Handler">
77+
<field name="visibility" origin="table_name.field_name" handler="handler" xsi:type="filter" dataType="string"/>
78+
</fields>
79+
</indexer>
80+
</config>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../app/code/Magento/Indexer/etc/indexer.xsd">
9+
<indexer id="indexer_1" view_id="catalogsearch_fulltext" class="Magento\CatalogSearch\Model\Indexer\Fulltext">
10+
<title translate="true">Test Indexer Declaration 1</title>
11+
<description translate="true">Test Indexer Declaration 1</description>
12+
<fields handler="Magento\Framework\Search\Index\Fields\Handler">
13+
<field name="title" origin="table_name.field_name" handler="Magento\Framework\Search\Index\Field\Handler\Class" xsi:type="both">
14+
<filter class="Magento\Framework\Search\Index\Filter\StopWordsFilter"/>
15+
</field>
16+
<field name="description" origin="table_name.field_name" handler="Magento\Framework\Search\Index\Field\Handler\Class" xsi:type="match">
17+
<filter class="Magento\Framework\Search\Index\Filter\LowercaseFilter"/>
18+
</field>
19+
<field name="visibility" origin="table_name.field_name" handler="Magento\Framework\Search\Index\Field\Handler\Class" xsi:type="filter" dataType="int" />
20+
</fields>
21+
</indexer>
22+
</config>

0 commit comments

Comments
 (0)