Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MftfFilesystem.php
Go to the documentation of this file.
1 <?php
8 
12 
13 class MftfFilesystem extends \Magento\FunctionalTestingFramework\Config\Reader\Filesystem
14 {
22  public function readFiles($fileList)
23  {
24  $exceptionCollector = new ExceptionCollector();
26  $configMerger = null;
27  foreach ($fileList as $key => $content) {
28  //check if file is empty and continue to next if it is
29  if (!parent::verifyFileEmpty($content, $fileList->getFilename())) {
30  continue;
31  }
32  try {
33  if (!$configMerger) {
34  $configMerger = $this->createConfigMerger(
35  $this->domDocumentClass,
36  $content,
37  $fileList->getFilename(),
38  $exceptionCollector
39  );
40  } else {
41  $configMerger->merge($content, $fileList->getFilename(), $exceptionCollector);
42  }
43  if (MftfApplicationConfig::getConfig()->debugEnabled()) {
44  $this->validateSchema($configMerger, $fileList->getFilename());
45  }
46  } catch (\Magento\FunctionalTestingFramework\Config\Dom\ValidationException $e) {
47  throw new \Exception("Invalid XML in file " . $key . ":\n" . $e->getMessage());
48  }
49  }
50  $exceptionCollector->throwException();
51  if ($fileList->valid()) {
52  $this->validateSchema($configMerger, $fileList->getFilename());
53  }
54 
55  $output = [];
56  if ($configMerger) {
57  $output = $this->converter->convert($configMerger->getDom());
58  }
59  return $output;
60  }
61 
72  protected function createConfigMerger($mergerClass, $initialContents, $filename = null, $exceptionCollector = null)
73  {
74  $result = new $mergerClass(
75  $initialContents,
76  $filename,
77  $exceptionCollector,
78  $this->idAttributes,
79  null,
80  $this->perFileSchema
81  );
82  if (!$result instanceof \Magento\FunctionalTestingFramework\Config\Dom) {
83  throw new \UnexpectedValueException(
84  "Instance of the DOM config merger is expected, got {$mergerClass} instead."
85  );
86  }
87  return $result;
88  }
89 }
$fileList
Definition: export.php:13
createConfigMerger($mergerClass, $initialContents, $filename=null, $exceptionCollector=null)