Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
EventConfigFilesTest.php
Go to the documentation of this file.
1 <?php
7 
8 class EventConfigFilesTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $_schemaFile;
14 
15  protected function setUp()
16  {
18  $this->_schemaFile = $objectManager->get(\Magento\Framework\Event\Config\SchemaLocator::class)->getSchema();
19  }
20 
25  public function testEventConfigFiles($file)
26  {
27  $errors = [];
28  $validationStateMock = $this->createMock(\Magento\Framework\Config\ValidationStateInterface::class);
29  $validationStateMock->method('isValidationRequired')
30  ->willReturn(true);
31  $dom = new \Magento\Framework\Config\Dom(file_get_contents($file), $validationStateMock);
32  $result = $dom->validate($this->_schemaFile, $errors);
33  $message = "Invalid XML-file: {$file}\n";
34  foreach ($errors as $error) {
35  $message .= "{$error->message} Line: {$error->line}\n";
36  }
37  $this->assertTrue($result, $message);
38  }
39 
43  public function eventConfigFilesDataProvider()
44  {
45  return \Magento\Framework\App\Utility\Files::init()->getConfigFiles('{*/events.xml,events.xml}');
46  }
47 }
$objectManager
Definition: bootstrap.php:17
$message
$errors
Definition: overview.phtml:9