|
5 | 5 | */
|
6 | 6 | namespace Magento\FunctionalTestingFramework\Config\Reader;
|
7 | 7 |
|
| 8 | +use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig; |
| 9 | + |
8 | 10 | /**
|
9 | 11 | * Filesystem configuration loader. Loads configuration from XML files, split by scopes.
|
10 | 12 | */
|
@@ -150,24 +152,14 @@ protected function readFiles($fileList)
|
150 | 152 | } else {
|
151 | 153 | $configMerger->merge($content);
|
152 | 154 | }
|
153 |
| - if ($this->validationState->isValidationRequired()) { |
154 |
| - $errors = []; |
155 |
| - if ($configMerger && !$configMerger->validate($this->schemaFile, $errors)) { |
156 |
| - $message = $fileList->getFilename() . PHP_EOL . "Invalid Document \n"; |
157 |
| - throw new \Exception($message . implode("\n", $errors)); |
158 |
| - } |
| 155 | + if (MftfApplicationConfig::getConfig()->debugEnabled()) { |
| 156 | + $this->validateSchema($configMerger, $fileList->getFilename()); |
159 | 157 | }
|
160 | 158 | } catch (\Magento\FunctionalTestingFramework\Config\Dom\ValidationException $e) {
|
161 | 159 | throw new \Exception("Invalid XML in file " . $fileList->getFilename() . ":\n" . $e->getMessage());
|
162 | 160 | }
|
163 | 161 | }
|
164 |
| - if ($this->validationState->isValidationRequired()) { |
165 |
| - $errors = []; |
166 |
| - if ($configMerger && !$configMerger->validate($this->schemaFile, $errors)) { |
167 |
| - $message = "Invalid Document \n"; |
168 |
| - throw new \Exception($message . implode("\n", $errors)); |
169 |
| - } |
170 |
| - } |
| 162 | + $this->validateSchema($configMerger); |
171 | 163 |
|
172 | 164 | $output = [];
|
173 | 165 | if ($configMerger) {
|
@@ -199,4 +191,23 @@ protected function createConfigMerger($mergerClass, $initialContents)
|
199 | 191 | }
|
200 | 192 | return $result;
|
201 | 193 | }
|
| 194 | + |
| 195 | + /** |
| 196 | + * Validate read xml against expected schema |
| 197 | + * |
| 198 | + * @param string $configMerger |
| 199 | + * @param string $filename |
| 200 | + * @throws \Exception |
| 201 | + * @return void |
| 202 | + */ |
| 203 | + protected function validateSchema($configMerger, $filename = null) |
| 204 | + { |
| 205 | + if ($this->validationState->isValidationRequired()) { |
| 206 | + $errors = []; |
| 207 | + if ($configMerger && !$configMerger->validate($this->schemaFile, $errors)) { |
| 208 | + $message = $filename ? $filename . PHP_EOL . "Invalid Document \n" : PHP_EOL . "Invalid Document \n"; |
| 209 | + throw new \Exception($message . implode("\n", $errors)); |
| 210 | + } |
| 211 | + } |
| 212 | + } |
202 | 213 | }
|
0 commit comments