Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RequestConfigTest.php
Go to the documentation of this file.
1 <?php
9 
11 {
13  protected $urnResolver;
14 
15  protected function setUp()
16  {
17  $this->urnResolver = new \Magento\Framework\Config\Dom\UrnResolver();
18  }
19 
25  protected function _getXsd()
26  {
27  return $this->urnResolver->getRealPath('urn:magento:framework:Search/etc/search_request_merged.xsd');
28  }
29 
35  protected function _getFileXsd()
36  {
37  return $this->urnResolver->getRealPath('urn:magento:framework:Search/etc/search_request.xsd');
38  }
39 
45  protected function _getKnownValidXml()
46  {
47  return __DIR__ . '/_files/request/valid.xml';
48  }
49 
55  protected function _getKnownInvalidXml()
56  {
57  return __DIR__ . '/_files/request/invalid.xml';
58  }
59 
65  protected function _getKnownValidPartialXml()
66  {
67  return __DIR__ . '/_files/request/valid_partial.xml';
68  }
69 
73  public function testSchemaUsingInvalidXml($expectedErrors = null)
74  {
75  $expectedErrors = array_filter(
76  explode(
77  "\n",
78  "
79 No match found for key-sequence ['suggested_search_container'] of keyref 'requestQueryReference'.
80 Element 'queryReference': No match found for key-sequence ['fulltext_search_query4'] of keyref 'queryReference'.
81 "
82  )
83  );
84  parent::testSchemaUsingInvalidXml($expectedErrors);
85  }
86 
90  public function testFileSchemaUsingInvalidXml($expectedErrors = null)
91  {
92  $expectedErrors = array_filter(
93  explode(
94  "\n",
95  "
96 Element 'dimensions': Missing child element(s). Expected is ( dimension ).
97 Element 'queryReference': The attribute 'clause' is required but missing.
98 Element 'queryReference': The attribute 'ref' is required but missing.
99 Element 'filterReference': The attribute 'clause' is required but missing.
100 Element 'filterReference': The attribute 'ref' is required but missing.
101 Element 'filter': The attribute 'field' is required but missing.
102 Element 'metric', attribute 'type': [facet 'enumeration'] " .
103  "The value 'sumasdasd' is not an element of the set {'sum', 'count', 'min', 'max', 'avg'}.
104 Element 'metric', attribute 'type': 'sumasdasd' is not a valid value of the local atomic type.
105 Element 'bucket': Missing child element(s). Expected is one of ( metrics, ranges ).
106 Element 'request': Missing child element(s). Expected is ( from )."
107  )
108  );
109  parent::testFileSchemaUsingInvalidXml($expectedErrors);
110  }
111 
117  protected function _getXmlName()
118  {
119  return 'search_request.xml';
120  }
121 
127  protected function _getKnownInvalidPartialXml()
128  {
129  return __DIR__ . '/_files/request/invalid_partial.xml';
130  }
131 
132  public function testSchemaUsingValidXml()
133  {
134  parent::testSchemaUsingValidXml();
135  }
136 }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60