1
1
<?php
2
+
2
3
/**
3
4
* Copyright © Magento, Inc. All rights reserved.
4
5
* See COPYING.txt for license details.
5
6
*/
7
+
6
8
declare (strict_types=1 );
7
9
8
10
namespace Magento \Framework \MessageQueue \Test \Unit \Topology \Config \QueueConfigItem ;
9
11
10
12
use Magento \Framework \Communication \ConfigInterface as CommunicationConfig ;
13
+ use Magento \Framework \Exception \LocalizedException ;
11
14
use Magento \Framework \MessageQueue \Rpc \ResponseQueueNameBuilder ;
12
15
use Magento \Framework \MessageQueue \Topology \Config \Data ;
13
16
use Magento \Framework \MessageQueue \Topology \Config \QueueConfigItem \DataMapper ;
17
20
class DataMapperTest extends TestCase
18
21
{
19
22
/**
20
- * @var MockObject
23
+ * @var Data| MockObject
21
24
*/
22
- private $ configData ;
25
+ private $ configDataMock ;
23
26
24
27
/**
25
- * @var MockObject
28
+ * @var CommunicationConfig| MockObject
26
29
*/
27
- private $ communicationConfig ;
30
+ private $ communicationConfigMock ;
28
31
29
32
/**
30
- * @var MockObject
33
+ * @var ResponseQueueNameBuilder| MockObject
31
34
*/
32
- private $ queueNameBuilder ;
35
+ private $ queueNameBuilderMock ;
33
36
34
37
/**
35
38
* @var DataMapper
36
39
*/
37
40
private $ model ;
38
41
42
+ /**
43
+ * @return void
44
+ */
39
45
protected function setUp (): void
40
46
{
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
+ );
45
55
}
46
56
47
- public function testGetMappedData ()
57
+ /**
58
+ * @return void
59
+ *
60
+ * @throws LocalizedException
61
+ */
62
+ public function testGetMappedData (): void
48
63
{
49
64
$ data = [
50
65
'ex01 ' => [
@@ -100,9 +115,11 @@ public function testGetMappedData()
100
115
['topic02 ' , ['name ' => 'topic02 ' , 'is_synchronous ' => false ]],
101
116
];
102
117
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 ())
106
123
->method ('getQueueName ' )
107
124
->with ('topic01 ' )
108
125
->willReturn ('responseQueue.topic01 ' );
@@ -114,23 +131,27 @@ public function testGetMappedData()
114
131
'connection ' => 'amqp ' ,
115
132
'durable ' => true ,
116
133
'autoDelete ' => false ,
117
- 'arguments ' => [],
134
+ 'arguments ' => [' some ' => ' arguments ' ],
118
135
],
119
136
'some.queue--amqp ' => [
120
137
'name ' => 'some.queue ' ,
121
138
'connection ' => 'amqp ' ,
122
139
'durable ' => true ,
123
140
'autoDelete ' => false ,
124
- 'arguments ' => [],
141
+ 'arguments ' => [' some ' => ' arguments ' ],
125
142
],
126
143
];
127
144
$ this ->assertEquals ($ expectedResult , $ actualResult );
128
145
}
129
146
130
147
/**
148
+ * @return void
149
+ *
150
+ * @throws LocalizedException
151
+ *
131
152
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
132
153
*/
133
- public function testGetMappedDataForWildcard ()
154
+ public function testGetMappedDataForWildcard (): void
134
155
{
135
156
$ data = [
136
157
'ex01 ' => [
@@ -200,13 +221,15 @@ public function testGetMappedDataForWildcard()
200
221
'topic08.part2.some.test ' => ['name ' => 'topic08.part2.some.test ' , 'is_synchronous ' => true ],
201
222
];
202
223
203
- $ this ->communicationConfig ->expects ($ this ->once ())
224
+ $ this ->communicationConfigMock ->expects ($ this ->once ())
204
225
->method ('getTopic ' )
205
226
->with ('topic01 ' )
206
227
->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 ())
210
233
->method ('getQueueName ' )
211
234
->willReturnCallback (function ($ value ) {
212
235
return 'responseQueue. ' . $ value ;
@@ -219,49 +242,49 @@ public function testGetMappedDataForWildcard()
219
242
'connection ' => 'amqp ' ,
220
243
'durable ' => true ,
221
244
'autoDelete ' => false ,
222
- 'arguments ' => [],
245
+ 'arguments ' => [' some ' => ' arguments ' ],
223
246
],
224
247
'some.queue--amqp ' => [
225
248
'name ' => 'some.queue ' ,
226
249
'connection ' => 'amqp ' ,
227
250
'durable ' => true ,
228
251
'autoDelete ' => false ,
229
- 'arguments ' => [],
252
+ 'arguments ' => [' some ' => ' arguments ' ],
230
253
],
231
254
'responseQueue.topic02--amqp ' => [
232
255
'name ' => 'responseQueue.topic02 ' ,
233
256
'connection ' => 'amqp ' ,
234
257
'durable ' => true ,
235
258
'autoDelete ' => false ,
236
- 'arguments ' => [],
259
+ 'arguments ' => [' some ' => ' arguments ' ],
237
260
],
238
261
'responseQueue.topic03--amqp ' => [
239
262
'name ' => 'responseQueue.topic03 ' ,
240
263
'connection ' => 'amqp ' ,
241
264
'durable ' => true ,
242
265
'autoDelete ' => false ,
243
- 'arguments ' => [],
266
+ 'arguments ' => [' some ' => ' arguments ' ],
244
267
],
245
268
'responseQueue.topic04.04.04--amqp ' => [
246
269
'name ' => 'responseQueue.topic04.04.04 ' ,
247
270
'connection ' => 'amqp ' ,
248
271
'durable ' => true ,
249
272
'autoDelete ' => false ,
250
- 'arguments ' => [],
273
+ 'arguments ' => [' some ' => ' arguments ' ],
251
274
],
252
275
'responseQueue.topic05.05--amqp ' => [
253
276
'name ' => 'responseQueue.topic05.05 ' ,
254
277
'connection ' => 'amqp ' ,
255
278
'durable ' => true ,
256
279
'autoDelete ' => false ,
257
- 'arguments ' => [],
280
+ 'arguments ' => [' some ' => ' arguments ' ],
258
281
],
259
282
'responseQueue.topic08.part2.some.test--amqp ' => [
260
283
'name ' => 'responseQueue.topic08.part2.some.test ' ,
261
284
'connection ' => 'amqp ' ,
262
285
'durable ' => true ,
263
286
'autoDelete ' => false ,
264
- 'arguments ' => [],
287
+ 'arguments ' => [' some ' => ' arguments ' ],
265
288
]
266
289
];
267
290
$ this ->assertEquals ($ expectedResult , $ actualResult );
0 commit comments