EventConfigFilesTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Test\Integrity\Modular;
  7. class EventConfigFilesTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var string
  11. */
  12. protected $_schemaFile;
  13. protected function setUp()
  14. {
  15. $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  16. $this->_schemaFile = $objectManager->get(\Magento\Framework\Event\Config\SchemaLocator::class)->getSchema();
  17. }
  18. /**
  19. * @param string $file
  20. * @dataProvider eventConfigFilesDataProvider
  21. */
  22. public function testEventConfigFiles($file)
  23. {
  24. $errors = [];
  25. $validationStateMock = $this->createMock(\Magento\Framework\Config\ValidationStateInterface::class);
  26. $validationStateMock->method('isValidationRequired')
  27. ->willReturn(true);
  28. $dom = new \Magento\Framework\Config\Dom(file_get_contents($file), $validationStateMock);
  29. $result = $dom->validate($this->_schemaFile, $errors);
  30. $message = "Invalid XML-file: {$file}\n";
  31. foreach ($errors as $error) {
  32. $message .= "{$error->message} Line: {$error->line}\n";
  33. }
  34. $this->assertTrue($result, $message);
  35. }
  36. /**
  37. * @return array
  38. */
  39. public function eventConfigFilesDataProvider()
  40. {
  41. return \Magento\Framework\App\Utility\Files::init()->getConfigFiles('{*/events.xml,events.xml}');
  42. }
  43. }