11<?php
2+
23/**
34 * Copyright © Magento, Inc. All rights reserved.
45 * See COPYING.txt for license details.
56 */
7+
68declare (strict_types=1 );
79
810namespace Magento \Framework \MessageQueue \Test \Unit \Topology \Config \QueueConfigItem ;
911
1012use Magento \Framework \Communication \ConfigInterface as CommunicationConfig ;
13+ use Magento \Framework \Exception \LocalizedException ;
1114use Magento \Framework \MessageQueue \Rpc \ResponseQueueNameBuilder ;
1215use Magento \Framework \MessageQueue \Topology \Config \Data ;
1316use Magento \Framework \MessageQueue \Topology \Config \QueueConfigItem \DataMapper ;
1720class DataMapperTest extends TestCase
1821{
1922 /**
20- * @var MockObject
23+ * @var Data| MockObject
2124 */
22- private $ configData ;
25+ private $ configDataMock ;
2326
2427 /**
25- * @var MockObject
28+ * @var CommunicationConfig| MockObject
2629 */
27- private $ communicationConfig ;
30+ private $ communicationConfigMock ;
2831
2932 /**
30- * @var MockObject
33+ * @var ResponseQueueNameBuilder| MockObject
3134 */
32- private $ queueNameBuilder ;
35+ private $ queueNameBuilderMock ;
3336
3437 /**
3538 * @var DataMapper
3639 */
3740 private $ model ;
3841
42+ /**
43+ * @return void
44+ */
3945 protected function setUp (): void
4046 {
41- $ this ->configData = $ this ->createMock (Data::class);
42- $ this ->communicationConfig = $ this ->createMock (CommunicationConfig::class);
43- $ this ->queueNameBuilder = $ this ->createMock (ResponseQueueNameBuilder::class);
44- $ this ->model = new DataMapper ($ this ->configData , $ this ->communicationConfig , $ this ->queueNameBuilder );
47+ $ this ->configDataMock = $ this ->createMock (Data::class);
48+ $ this ->communicationConfigMock = $ this ->createMock (CommunicationConfig::class);
49+ $ this ->queueNameBuilderMock = $ this ->createMock (ResponseQueueNameBuilder::class);
50+ $ this ->model = new DataMapper (
51+ $ this ->configDataMock ,
52+ $ this ->communicationConfigMock ,
53+ $ this ->queueNameBuilderMock
54+ );
4555 }
4656
47- public function testGetMappedData ()
57+ /**
58+ * @return void
59+ *
60+ * @throws LocalizedException
61+ */
62+ public function testGetMappedData (): void
4863 {
4964 $ data = [
5065 'ex01 ' => [
@@ -100,9 +115,11 @@ public function testGetMappedData()
100115 ['topic02 ' , ['name ' => 'topic02 ' , 'is_synchronous ' => false ]],
101116 ];
102117
103- $ this ->communicationConfig ->expects ($ this ->exactly (2 ))->method ('getTopic ' )->willReturnMap ($ communicationMap );
104- $ this ->configData ->expects ($ this ->once ())->method ('get ' )->willReturn ($ data );
105- $ this ->queueNameBuilder ->expects ($ this ->once ())
118+ $ this ->communicationConfigMock ->expects ($ this ->exactly (2 ))
119+ ->method ('getTopic ' )
120+ ->willReturnMap ($ communicationMap );
121+ $ this ->configDataMock ->expects ($ this ->once ())->method ('get ' )->willReturn ($ data );
122+ $ this ->queueNameBuilderMock ->expects ($ this ->once ())
106123 ->method ('getQueueName ' )
107124 ->with ('topic01 ' )
108125 ->willReturn ('responseQueue.topic01 ' );
@@ -114,23 +131,27 @@ public function testGetMappedData()
114131 'connection ' => 'amqp ' ,
115132 'durable ' => true ,
116133 'autoDelete ' => false ,
117- 'arguments ' => [],
134+ 'arguments ' => [' some ' => ' arguments ' ],
118135 ],
119136 'some.queue--amqp ' => [
120137 'name ' => 'some.queue ' ,
121138 'connection ' => 'amqp ' ,
122139 'durable ' => true ,
123140 'autoDelete ' => false ,
124- 'arguments ' => [],
141+ 'arguments ' => [' some ' => ' arguments ' ],
125142 ],
126143 ];
127144 $ this ->assertEquals ($ expectedResult , $ actualResult );
128145 }
129146
130147 /**
148+ * @return void
149+ *
150+ * @throws LocalizedException
151+ *
131152 * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
132153 */
133- public function testGetMappedDataForWildcard ()
154+ public function testGetMappedDataForWildcard (): void
134155 {
135156 $ data = [
136157 'ex01 ' => [
@@ -200,13 +221,15 @@ public function testGetMappedDataForWildcard()
200221 'topic08.part2.some.test ' => ['name ' => 'topic08.part2.some.test ' , 'is_synchronous ' => true ],
201222 ];
202223
203- $ this ->communicationConfig ->expects ($ this ->once ())
224+ $ this ->communicationConfigMock ->expects ($ this ->once ())
204225 ->method ('getTopic ' )
205226 ->with ('topic01 ' )
206227 ->willReturn (['name ' => 'topic01 ' , 'is_synchronous ' => true ]);
207- $ this ->communicationConfig ->expects ($ this ->any ())->method ('getTopics ' )->willReturn ($ communicationData );
208- $ this ->configData ->expects ($ this ->once ())->method ('get ' )->willReturn ($ data );
209- $ this ->queueNameBuilder ->expects ($ this ->any ())
228+ $ this ->communicationConfigMock ->expects ($ this ->any ())
229+ ->method ('getTopics ' )
230+ ->willReturn ($ communicationData );
231+ $ this ->configDataMock ->expects ($ this ->once ())->method ('get ' )->willReturn ($ data );
232+ $ this ->queueNameBuilderMock ->expects ($ this ->any ())
210233 ->method ('getQueueName ' )
211234 ->willReturnCallback (function ($ value ) {
212235 return 'responseQueue. ' . $ value ;
@@ -219,49 +242,49 @@ public function testGetMappedDataForWildcard()
219242 'connection ' => 'amqp ' ,
220243 'durable ' => true ,
221244 'autoDelete ' => false ,
222- 'arguments ' => [],
245+ 'arguments ' => [' some ' => ' arguments ' ],
223246 ],
224247 'some.queue--amqp ' => [
225248 'name ' => 'some.queue ' ,
226249 'connection ' => 'amqp ' ,
227250 'durable ' => true ,
228251 'autoDelete ' => false ,
229- 'arguments ' => [],
252+ 'arguments ' => [' some ' => ' arguments ' ],
230253 ],
231254 'responseQueue.topic02--amqp ' => [
232255 'name ' => 'responseQueue.topic02 ' ,
233256 'connection ' => 'amqp ' ,
234257 'durable ' => true ,
235258 'autoDelete ' => false ,
236- 'arguments ' => [],
259+ 'arguments ' => [' some ' => ' arguments ' ],
237260 ],
238261 'responseQueue.topic03--amqp ' => [
239262 'name ' => 'responseQueue.topic03 ' ,
240263 'connection ' => 'amqp ' ,
241264 'durable ' => true ,
242265 'autoDelete ' => false ,
243- 'arguments ' => [],
266+ 'arguments ' => [' some ' => ' arguments ' ],
244267 ],
245268 'responseQueue.topic04.04.04--amqp ' => [
246269 'name ' => 'responseQueue.topic04.04.04 ' ,
247270 'connection ' => 'amqp ' ,
248271 'durable ' => true ,
249272 'autoDelete ' => false ,
250- 'arguments ' => [],
273+ 'arguments ' => [' some ' => ' arguments ' ],
251274 ],
252275 'responseQueue.topic05.05--amqp ' => [
253276 'name ' => 'responseQueue.topic05.05 ' ,
254277 'connection ' => 'amqp ' ,
255278 'durable ' => true ,
256279 'autoDelete ' => false ,
257- 'arguments ' => [],
280+ 'arguments ' => [' some ' => ' arguments ' ],
258281 ],
259282 'responseQueue.topic08.part2.some.test--amqp ' => [
260283 'name ' => 'responseQueue.topic08.part2.some.test ' ,
261284 'connection ' => 'amqp ' ,
262285 'durable ' => true ,
263286 'autoDelete ' => false ,
264- 'arguments ' => [],
287+ 'arguments ' => [' some ' => ' arguments ' ],
265288 ]
266289 ];
267290 $ this ->assertEquals ($ expectedResult , $ actualResult );
0 commit comments