DataCollectorTest.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Deploy\Test\Unit\Model\DeploymentConfig;
  7. use Magento\Deploy\Model\DeploymentConfig\DataCollector;
  8. use Magento\Deploy\Model\DeploymentConfig\ImporterPool;
  9. use Magento\Framework\App\DeploymentConfig;
  10. class DataCollectorTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @var ImporterPool|\PHPUnit_Framework_MockObject_MockObject
  14. */
  15. private $configImporterPoolMock;
  16. /**
  17. * @var DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject
  18. */
  19. private $deploymentConfigMock;
  20. /**
  21. * @var DataCollector
  22. */
  23. private $dataCollector;
  24. /**
  25. * @return void
  26. */
  27. protected function setUp()
  28. {
  29. $this->configImporterPoolMock = $this->getMockBuilder(ImporterPool::class)
  30. ->disableOriginalConstructor()
  31. ->getMock();
  32. $this->deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class)
  33. ->disableOriginalConstructor()
  34. ->getMock();
  35. $this->dataCollector = new DataCollector($this->configImporterPoolMock, $this->deploymentConfigMock);
  36. }
  37. /**
  38. * @return void
  39. */
  40. public function testGetConfig()
  41. {
  42. $sections = ['first', 'second'];
  43. $this->configImporterPoolMock->expects($this->once())
  44. ->method('getSections')
  45. ->willReturn($sections);
  46. $this->deploymentConfigMock->expects($this->atLeastOnce())
  47. ->method('getConfigData')
  48. ->willReturnMap([['first', 'some data']]);
  49. $this->assertSame(['first' => 'some data', 'second' => null], $this->dataCollector->getConfig());
  50. }
  51. /**
  52. * @return void
  53. */
  54. public function testGetConfigSpecificSection()
  55. {
  56. $this->configImporterPoolMock->expects($this->never())
  57. ->method('getSections');
  58. $this->deploymentConfigMock->expects($this->atLeastOnce())
  59. ->method('getConfigData')
  60. ->willReturnMap([['someSection', 'some data']]);
  61. $this->assertSame(['someSection' => 'some data'], $this->dataCollector->getConfig('someSection'));
  62. }
  63. }