Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigSourceAggregatedTest.php
Go to the documentation of this file.
1 <?php
7 
10 
11 class ConfigSourceAggregatedTest extends \PHPUnit\Framework\TestCase
12 {
16  private $sourceMock;
17 
21  private $sourceMockTwo;
22 
26  private $source;
27 
28  public function setUp()
29  {
30  $this->sourceMock = $this->getMockBuilder(ConfigSourceInterface::class)
31  ->getMockForAbstractClass();
32  $this->sourceMockTwo = $this->getMockBuilder(ConfigSourceInterface::class)
33  ->getMockForAbstractClass();
34 
35  $sources = [
36  [
37  'source' => $this->sourceMockTwo,
38  'sortOrder' => 100
39  ],
40  [
41  'source' => $this->sourceMock,
42  'sortOrder' => 10
43  ],
44 
45  ];
46 
47  $this->source = new ConfigSourceAggregated($sources);
48  }
49 
50  public function testGet()
51  {
52  $path = 'path';
53  $this->sourceMock->expects($this->once())
54  ->method('get')
55  ->with($path)
56  ->willReturn(['key' => 'value1', 'test' => false]);
57  $this->sourceMockTwo->expects($this->once())
58  ->method('get')
59  ->with($path)
60  ->willReturn(['key' => 'value2']);
61  $this->assertEquals(
62  [
63  'test' => false,
64  'key' => 'value2'
65  ],
66  $this->source->get($path)
67  );
68  }
69 }