AclConfigFilesTest.php 1.5 KB

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