SystemConfigFilesTest.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. use Magento\Framework\Component\ComponentRegistrar;
  9. class SystemConfigFilesTest extends \PHPUnit\Framework\TestCase
  10. {
  11. public function testConfiguration()
  12. {
  13. $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  14. // disable config caching to not pollute it
  15. /** @var $cacheState \Magento\Framework\App\Cache\StateInterface */
  16. $cacheState = $objectManager->get(\Magento\Framework\App\Cache\StateInterface::class);
  17. $cacheState->setEnabled(\Magento\Framework\App\Cache\Type\Config::TYPE_IDENTIFIER, false);
  18. /** @var \Magento\Framework\Filesystem $filesystem */
  19. $filesystem = $objectManager->get(\Magento\Framework\Filesystem::class);
  20. $modulesDir = $filesystem->getDirectoryRead(DirectoryList::ROOT);
  21. /** @var $moduleDirSearch \Magento\Framework\Component\DirSearch */
  22. $moduleDirSearch = $objectManager->get(\Magento\Framework\Component\DirSearch::class);
  23. $fileList = $moduleDirSearch
  24. ->collectFiles(ComponentRegistrar::MODULE, 'etc/adminhtml/system.xml');
  25. $configMock = $this->createPartialMock(
  26. \Magento\Framework\Module\Dir\Reader::class,
  27. ['getConfigurationFiles', 'getModuleDir']
  28. );
  29. $configMock->expects($this->any())->method('getConfigurationFiles')->will($this->returnValue($fileList));
  30. $configMock->expects(
  31. $this->any()
  32. )->method(
  33. 'getModuleDir'
  34. )->with(
  35. 'etc',
  36. 'Magento_Backend'
  37. )->will(
  38. $this->returnValue($modulesDir->getAbsolutePath() . '/app/code/Magento/Backend/etc')
  39. );
  40. try {
  41. $objectManager->create(
  42. \Magento\Config\Model\Config\Structure\Reader::class,
  43. ['moduleReader' => $configMock, 'runtimeValidation' => true]
  44. );
  45. } catch (\Magento\Framework\Exception\LocalizedException $exp) {
  46. $this->fail($exp->getMessage());
  47. }
  48. }
  49. }