Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigOptionsListCollectorTest.php
Go to the documentation of this file.
1 <?php
7 
8 class ConfigOptionsListCollectorTest extends \PHPUnit\Framework\TestCase
9 {
13  private $objectManagerProvider;
14 
15  public function setUp()
16  {
17  $this->objectManagerProvider = $this->createMock(\Magento\Setup\Model\ObjectManagerProvider::class);
18  $this->objectManagerProvider
19  ->expects($this->any())
20  ->method('get')
21  ->willReturn(\Magento\TestFramework\Helper\Bootstrap::getObjectManager());
22  }
23 
24  public function testCollectOptionsLists()
25  {
27  $fullModuleListMock = $this->createMock(\Magento\Framework\Module\FullModuleList::class);
28  $fullModuleListMock->expects($this->once())->method('getNames')->willReturn(['Magento_Backend']);
29 
30  $dbValidator = $this->createMock(\Magento\Setup\Validator\DbValidator::class);
31  $configGenerator = $this->createMock(\Magento\Setup\Model\ConfigGenerator::class);
32 
34  ->create(
35  \Magento\Setup\Model\ConfigOptionsList::class,
36  [
37  'configGenerator' => $configGenerator,
38  'dbValidator' => $dbValidator
39  ]
40  );
41 
42  $serviceLocator = $this->getMockForAbstractClass(\Zend\ServiceManager\ServiceLocatorInterface::class);
43 
44  $serviceLocator->expects($this->once())
45  ->method('get')
46  ->with(\Magento\Setup\Model\ConfigOptionsList::class)
47  ->willReturn($setupOptions);
48 
50  $object = $objectManager->create(
51  \Magento\Setup\Model\ConfigOptionsListCollector::class,
52  [
53  'objectManagerProvider' => $this->objectManagerProvider,
54  'fullModuleList' => $fullModuleListMock,
55  'serviceLocator' => $serviceLocator
56  ]
57  );
58  $result = $object->collectOptionsLists();
59 
60  $backendOptions = new \Magento\Backend\Setup\ConfigOptionsList();
61  $expected = [
62  'setup' => $setupOptions,
63  'Magento_Backend' => $backendOptions,
64  ];
65 
66  $this->assertEquals($expected, $result);
67  }
68 }
$objectManager
Definition: bootstrap.php:17