Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SystemConfigFilesTest.php
Go to the documentation of this file.
1 <?php
7 
10 
11 class SystemConfigFilesTest extends \PHPUnit\Framework\TestCase
12 {
13  public function testConfiguration()
14  {
16 
17  // disable config caching to not pollute it
19  $cacheState = $objectManager->get(\Magento\Framework\App\Cache\StateInterface::class);
20  $cacheState->setEnabled(\Magento\Framework\App\Cache\Type\Config::TYPE_IDENTIFIER, false);
21 
23  $filesystem = $objectManager->get(\Magento\Framework\Filesystem::class);
24  $modulesDir = $filesystem->getDirectoryRead(DirectoryList::ROOT);
26  $moduleDirSearch = $objectManager->get(\Magento\Framework\Component\DirSearch::class);
27  $fileList = $moduleDirSearch
28  ->collectFiles(ComponentRegistrar::MODULE, 'etc/adminhtml/system.xml');
29  $configMock = $this->createPartialMock(
30  \Magento\Framework\Module\Dir\Reader::class,
31  ['getConfigurationFiles', 'getModuleDir']
32  );
33  $configMock->expects($this->any())->method('getConfigurationFiles')->will($this->returnValue($fileList));
34  $configMock->expects(
35  $this->any()
36  )->method(
37  'getModuleDir'
38  )->with(
39  'etc',
40  'Magento_Backend'
41  )->will(
42  $this->returnValue($modulesDir->getAbsolutePath() . '/app/code/Magento/Backend/etc')
43  );
44  try {
45  $objectManager->create(
46  \Magento\Config\Model\Config\Structure\Reader::class,
47  ['moduleReader' => $configMock, 'runtimeValidation' => true]
48  );
49  } catch (\Magento\Framework\Exception\LocalizedException $exp) {
50  $this->fail($exp->getMessage());
51  }
52  }
53 }
$objectManager
Definition: bootstrap.php:17
$fileList
Definition: export.php:13
$filesystem