Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigReaderPluginTest.php
Go to the documentation of this file.
1 <?php
7 
11 use Magento\Framework\MessageQueue\Publisher\Config\CompositeReader as PublisherConfigCompositeReader;
12 
13 class ConfigReaderPluginTest extends \PHPUnit\Framework\TestCase
14 {
18  private $plugin;
19 
23  private $objectManagerHelper;
24 
28  private $configMock;
29 
33  private $subjectMock;
34 
35  protected function setUp()
36  {
37  $this->configMock = $this->getMockBuilder(ConfigInterface::class)
38  ->getMockForAbstractClass();
39  $this->subjectMock = $this->getMockBuilder(PublisherConfigCompositeReader::class)
40  ->disableOriginalConstructor()
41  ->getMock();
42 
43  $this->objectManagerHelper = new ObjectManagerHelper($this);
44  $this->plugin = $this->objectManagerHelper->getObject(
45  PublisherConfigReaderPlugin::class,
46  ['config' => $this->configMock]
47  );
48  }
49 
50  public function testAfterRead()
51  {
52  $result = ['topic0' => []];
53  $binds = [
54  [
55  'topic' => 'topic1',
56  'exchange' => 'exchange1'
57  ],
58  [
59  'topic' => 'topic2',
60  'exchange' => 'exchange2'
61  ]
62  ];
63  $finalResult = [
64  'topic1' => [
65  'topic' => 'topic1',
66  'connection' => [
67  'name' => 'connection1',
68  'exchange' => 'exchange1',
69  'disabled' => false
70  ],
71  'disabled' => false
72  ],
73  'topic2' => [
74  'topic' => 'topic2',
75  'connection' => [
76  'name' => 'connection2',
77  'exchange' => 'exchange2',
78  'disabled' => false
79  ],
80  'disabled' => false
81  ],
82  'topic0' => []
83  ];
84 
85  $this->configMock->expects(static::atLeastOnce())
86  ->method('getBinds')
87  ->willReturn($binds);
88  $this->configMock->expects(static::atLeastOnce())
89  ->method('getConnectionByTopic')
90  ->willReturnMap(
91  [
92  ['topic1', 'connection1'],
93  ['topic2', 'connection2']
94  ]
95  );
96 
97  $this->assertEquals($finalResult, $this->plugin->afterRead($this->subjectMock, $result));
98  }
99 }
return false
Definition: gallery.phtml:36