MviewConfigFilesTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. use Magento\Framework\App\Filesystem\DirectoryList;
  8. class MviewConfigFilesTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /**
  11. * Configuration acl file list
  12. *
  13. * @var array
  14. */
  15. protected $fileList = [];
  16. /**
  17. * Path to scheme file
  18. *
  19. * @var string
  20. */
  21. protected $schemaFile;
  22. protected function setUp()
  23. {
  24. $urnResolver = new \Magento\Framework\Config\Dom\UrnResolver();
  25. $this->schemaFile = $urnResolver->getRealPath('urn:magento:framework:Mview/etc/mview.xsd');
  26. }
  27. /**
  28. * Test each acl configuration file
  29. * @param string $file
  30. * @dataProvider mviewConfigFileDataProvider
  31. */
  32. public function testIndexerConfigFile($file)
  33. {
  34. $validationStateMock = $this->createMock(\Magento\Framework\Config\ValidationStateInterface::class);
  35. $validationStateMock->method('isValidationRequired')
  36. ->willReturn(true);
  37. $domConfig = new \Magento\Framework\Config\Dom(file_get_contents($file), $validationStateMock);
  38. $result = $domConfig->validate($this->schemaFile, $errors);
  39. $message = "Invalid XML-file: {$file}\n";
  40. foreach ($errors as $error) {
  41. $message .= "{$error}\n";
  42. }
  43. $this->assertTrue($result, $message);
  44. }
  45. /**
  46. * @return array
  47. */
  48. public function mviewConfigFileDataProvider()
  49. {
  50. return \Magento\Framework\App\Utility\Files::init()->getConfigFiles('mview.xml');
  51. }
  52. }