Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ResourcesConfigFilesTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class ResourcesConfigFilesTest extends \PHPUnit\Framework\TestCase
11 {
15  protected $_model;
16 
17  protected function setUp()
18  {
21  $moduleDirSearch = $objectManager->get(\Magento\Framework\Component\DirSearch::class);
22  $fileIteratorFactory = $objectManager->get(\Magento\Framework\Config\FileIteratorFactory::class);
23  $xmlFiles = $fileIteratorFactory->create(
24  $moduleDirSearch->collectFiles(ComponentRegistrar::MODULE, 'etc/{*/resources.xml,resources.xml}')
25  );
26 
27  $fileResolverMock = $this->createMock(\Magento\Framework\Config\FileResolverInterface::class);
28  $fileResolverMock->expects($this->any())->method('get')->will($this->returnValue($xmlFiles));
29  $validationStateMock = $this->createMock(\Magento\Framework\Config\ValidationStateInterface::class);
30  $validationStateMock->expects($this->any())->method('isValidationRequired')->will($this->returnValue(true));
31  $deploymentConfigMock = $this->createPartialMock(
32  \Magento\Framework\App\DeploymentConfig::class,
33  ['getConfiguration']
34  );
35  $deploymentConfigMock->expects($this->any())->method('getConfiguration')->will($this->returnValue([]));
37  $this->_model = $objectManager->create(
38  \Magento\Framework\App\ResourceConnection\Config\Reader::class,
39  [
40  'fileResolver' => $fileResolverMock,
41  'validationState' => $validationStateMock,
42  'deploymentConfig' => $deploymentConfigMock
43  ]
44  );
45  }
46 
47  public function testResourcesXmlFiles()
48  {
49  $this->_model->read('global');
50  }
51 }
$objectManager
Definition: bootstrap.php:17