ConfigSourceAggregatedTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\App\Test\Unit\Config;
  7. use Magento\Framework\App\Config\ConfigSourceAggregated;
  8. use Magento\Framework\App\Config\ConfigSourceInterface;
  9. class ConfigSourceAggregatedTest extends \PHPUnit\Framework\TestCase
  10. {
  11. /**
  12. * @var ConfigSourceInterface|\PHPUnit_Framework_MockObject_MockObject
  13. */
  14. private $sourceMock;
  15. /**
  16. * @var ConfigSourceInterface|\PHPUnit_Framework_MockObject_MockObject
  17. */
  18. private $sourceMockTwo;
  19. /**
  20. * @var ConfigSourceAggregated
  21. */
  22. private $source;
  23. public function setUp()
  24. {
  25. $this->sourceMock = $this->getMockBuilder(ConfigSourceInterface::class)
  26. ->getMockForAbstractClass();
  27. $this->sourceMockTwo = $this->getMockBuilder(ConfigSourceInterface::class)
  28. ->getMockForAbstractClass();
  29. $sources = [
  30. [
  31. 'source' => $this->sourceMockTwo,
  32. 'sortOrder' => 100
  33. ],
  34. [
  35. 'source' => $this->sourceMock,
  36. 'sortOrder' => 10
  37. ],
  38. ];
  39. $this->source = new ConfigSourceAggregated($sources);
  40. }
  41. public function testGet()
  42. {
  43. $path = 'path';
  44. $this->sourceMock->expects($this->once())
  45. ->method('get')
  46. ->with($path)
  47. ->willReturn(['key' => 'value1', 'test' => false]);
  48. $this->sourceMockTwo->expects($this->once())
  49. ->method('get')
  50. ->with($path)
  51. ->willReturn(['key' => 'value2']);
  52. $this->assertEquals(
  53. [
  54. 'test' => false,
  55. 'key' => 'value2'
  56. ],
  57. $this->source->get($path)
  58. );
  59. }
  60. }