@@ -17,7 +17,9 @@ class ConfigTest extends \PHPUnit\Framework\TestCase
17
17
*/
18
18
public function testGetTopics ()
19
19
{
20
- $ topics = $ this ->getConfigInstance (__DIR__ . '/_files/valid_communication.xml ' )->getTopics ();
20
+ $ topics = $ this ->getConfigInstance (
21
+ [__DIR__ . '/_files/valid_communication.xml ' , __DIR__ . '/_files/valid_communication_extra.xml ' ]
22
+ )->getTopics ();
21
23
$ expectedParsedTopics = include __DIR__ . '/_files/valid_communication_expected.php ' ;
22
24
$ this ->assertEquals ($ expectedParsedTopics , $ topics );
23
25
}
@@ -31,7 +33,7 @@ public function testGetTopicsNumeric()
31
33
$ this ->expectException (\LogicException::class);
32
34
$ this ->expectExceptionMessage ('Service method specified in the definition of topic "customerDeletedNumbers" is not av ' );
33
35
34
- $ this ->getConfigInstance (__DIR__ . '/_files/valid_communication_numeric.xml ' )->getTopics ();
36
+ $ this ->getConfigInstance ([ __DIR__ . '/_files/valid_communication_numeric.xml ' ] )->getTopics ();
35
37
}
36
38
37
39
// @codingStandardsIgnoreStart
@@ -58,15 +60,17 @@ public function testGetTopicsNumericInvalid()
58
60
$ this ->expectException (\Magento \Framework \Exception \LocalizedException::class);
59
61
$ this ->expectExceptionMessage ('The XML in file "0" is invalid: ' );
60
62
61
- $ this ->getConfigInstance (__DIR__ . '/_files/invalid_communication_numeric.xml ' )->getTopics ();
63
+ $ this ->getConfigInstance ([ __DIR__ . '/_files/invalid_communication_numeric.xml ' ] )->getTopics ();
62
64
}
63
65
64
66
/**
65
67
* Get topic configuration by its name
66
68
*/
67
69
public function testGetTopic ()
68
70
{
69
- $ topics = $ this ->getConfigInstance (__DIR__ . '/_files/valid_communication.xml ' )->getTopic ('customerCreated ' );
71
+ $ topics = $ this ->getConfigInstance (
72
+ [__DIR__ . '/_files/valid_communication.xml ' , __DIR__ . '/_files/valid_communication_extra.xml ' ]
73
+ )->getTopic ('customerCreated ' );
70
74
$ expectedParsedTopics = include __DIR__ . '/_files/valid_communication_expected.php ' ;
71
75
$ this ->assertEquals ($ expectedParsedTopics ['customerCreated ' ], $ topics );
72
76
}
@@ -80,7 +84,7 @@ public function testGetTopicInvalidName()
80
84
$ this ->expectException (\Magento \Framework \Exception \LocalizedException::class);
81
85
$ this ->expectExceptionMessage ('Topic "invalidTopic" is not configured. ' );
82
86
83
- $ this ->getConfigInstance (__DIR__ . '/_files/valid_communication.xml ' )->getTopic ('invalidTopic ' );
87
+ $ this ->getConfigInstance ([ __DIR__ . '/_files/valid_communication.xml ' ] )->getTopic ('invalidTopic ' );
84
88
}
85
89
86
90
/**
@@ -90,7 +94,7 @@ public function testGetTopicsExceptionMissingRequest()
90
94
$ this ->expectException (\LogicException::class);
91
95
$ this ->expectExceptionMessage ('Either "request" or "schema" attribute must be specified for topic "customerUpdated" ' );
92
96
93
- $ this ->getConfigInstance (__DIR__ . '/_files/communication_missing_request.xml ' )->getTopics ();
97
+ $ this ->getConfigInstance ([ __DIR__ . '/_files/communication_missing_request.xml ' ] )->getTopics ();
94
98
}
95
99
96
100
/**
@@ -100,7 +104,7 @@ public function testGetTopicsExceptionNotExistingServiceMethod()
100
104
$ this ->expectException (\LogicException::class);
101
105
$ this ->expectExceptionMessage ('Service method specified in the definition of topic "customerRetrieved" is not ' );
102
106
103
- $ this ->getConfigInstance (__DIR__ . '/_files/communication_not_existing_service_method.xml ' )->getTopics ();
107
+ $ this ->getConfigInstance ([ __DIR__ . '/_files/communication_not_existing_service_method.xml ' ] )->getTopics ();
104
108
}
105
109
106
110
/**
@@ -110,7 +114,7 @@ public function testGetTopicsExceptionNotExistingService()
110
114
$ this ->expectException (\LogicException::class);
111
115
$ this ->expectExceptionMessage ('Service method specified in the definition of topic "customerRetrieved" is not ' );
112
116
113
- $ this ->getConfigInstance (__DIR__ . '/_files/communication_not_existing_service.xml ' )->getTopics ();
117
+ $ this ->getConfigInstance ([ __DIR__ . '/_files/communication_not_existing_service.xml ' ] )->getTopics ();
114
118
}
115
119
116
120
/**
@@ -120,7 +124,7 @@ public function testGetTopicsExceptionNoAttributes()
120
124
$ this ->expectException (\LogicException::class);
121
125
$ this ->expectExceptionMessage ('Either "request" or "schema" attribute must be specified for topic "customerRetrieved" ' );
122
126
123
- $ this ->getConfigInstance (__DIR__ . '/_files/communication_no_attributes.xml ' )->getTopics ();
127
+ $ this ->getConfigInstance ([ __DIR__ . '/_files/communication_no_attributes.xml ' ] )->getTopics ();
124
128
}
125
129
126
130
/**
@@ -130,7 +134,7 @@ public function testGetTopicsExceptionInvalidResponseSchema()
130
134
$ this ->expectException (\LogicException::class);
131
135
$ this ->expectExceptionMessage ('Response schema definition for topic "customerUpdated" should reference existing ' );
132
136
133
- $ this ->getConfigInstance (__DIR__ . '/_files/communication_response_not_existing_service.xml ' )->getTopics ();
137
+ $ this ->getConfigInstance ([ __DIR__ . '/_files/communication_response_not_existing_service.xml ' ] )->getTopics ();
134
138
}
135
139
136
140
/**
@@ -140,7 +144,7 @@ public function testGetTopicsExceptionInvalidRequestSchema()
140
144
$ this ->expectException (\LogicException::class);
141
145
$ this ->expectExceptionMessage ('Request schema definition for topic "customerUpdated" should reference existing ' );
142
146
143
- $ this ->getConfigInstance (__DIR__ . '/_files/communication_request_not_existing_service.xml ' )->getTopics ();
147
+ $ this ->getConfigInstance ([ __DIR__ . '/_files/communication_request_not_existing_service.xml ' ] )->getTopics ();
144
148
}
145
149
146
150
/**
@@ -150,7 +154,7 @@ public function testGetTopicsExceptionMultipleHandlersSynchronousMode()
150
154
$ this ->expectException (\LogicException::class);
151
155
$ this ->expectExceptionMessage ('Topic "customerDeleted" is configured for synchronous requests, that is why it must ' );
152
156
153
- $ this ->getConfigInstance (__DIR__ . '/_files/communication_multiple_handlers_synchronous_mode.xml ' )->getTopics ();
157
+ $ this ->getConfigInstance ([ __DIR__ . '/_files/communication_multiple_handlers_synchronous_mode.xml ' ] )->getTopics ();
154
158
}
155
159
156
160
/**
@@ -160,7 +164,7 @@ public function testGetTopicsExceptionInvalidHandler()
160
164
$ this ->expectException (\LogicException::class);
161
165
$ this ->expectExceptionMessage ('Service method specified in the definition of handler "customHandler" for topic "custo ' );
162
166
163
- $ this ->getConfigInstance (__DIR__ . '/_files/communication_not_existing_handler_method.xml ' )->getTopics ();
167
+ $ this ->getConfigInstance ([ __DIR__ . '/_files/communication_not_existing_handler_method.xml ' ] )->getTopics ();
164
168
}
165
169
166
170
/**
@@ -171,7 +175,7 @@ public function testGetTopicsExceptionInvalidTopicNameInEnv()
171
175
$ this ->expectExceptionMessage ('Topic name "customerAdded" and attribute "name" = "customerCreated" must be equal ' );
172
176
173
177
$ this ->getConfigInstance (
174
- __DIR__ . '/_files/valid_communication.xml ' ,
178
+ [ __DIR__ . '/_files/valid_communication.xml ' ] ,
175
179
__DIR__ . '/_files/communication_invalid_topic_name.php '
176
180
)->getTopics ();
177
181
}
@@ -184,7 +188,7 @@ public function testGetTopicsExceptionTopicWithoutDataInEnv()
184
188
$ this ->expectExceptionMessage ('Topic "customerCreated" must contain data ' );
185
189
186
190
$ this ->getConfigInstance (
187
- __DIR__ . '/_files/valid_communication.xml ' ,
191
+ [ __DIR__ . '/_files/valid_communication.xml ' ] ,
188
192
__DIR__ . '/_files/communication_topic_without_data.php '
189
193
)->getTopics ();
190
194
}
@@ -197,7 +201,7 @@ public function testGetTopicsExceptionTopicWithMissedKeysInEnv()
197
201
$ this ->expectExceptionMessage ('Topic "customerCreated" has missed keys: [response] ' );
198
202
199
203
$ this ->getConfigInstance (
200
- __DIR__ . '/_files/valid_communication.xml ' ,
204
+ [ __DIR__ . '/_files/valid_communication.xml ' ] ,
201
205
__DIR__ . '/_files/communication_topic_with_missed_keys.php '
202
206
)->getTopics ();
203
207
}
@@ -210,7 +214,7 @@ public function testGetTopicsExceptionTopicWithExcessiveKeysInEnv()
210
214
$ this ->expectExceptionMessage ('Topic "customerCreated" has excessive keys: [some_incorrect_key] ' );
211
215
212
216
$ this ->getConfigInstance (
213
- __DIR__ . '/_files/valid_communication.xml ' ,
217
+ [ __DIR__ . '/_files/valid_communication.xml ' ] ,
214
218
__DIR__ . '/_files/communication_topic_with_excessive_keys.php '
215
219
)->getTopics ();
216
220
}
@@ -223,7 +227,7 @@ public function testGetTopicsExceptionTopicWithNonMatchedNameInEnv()
223
227
$ this ->expectExceptionMessage ('Topic name "customerDeleted" and attribute "name" = "customerRemoved" must be equal ' );
224
228
225
229
$ this ->getConfigInstance (
226
- __DIR__ . '/_files/valid_communication.xml ' ,
230
+ [ __DIR__ . '/_files/valid_communication.xml ' ] ,
227
231
__DIR__ . '/_files/communication_with_non_matched_name.php '
228
232
)->getTopics ();
229
233
}
@@ -236,7 +240,7 @@ public function testGetTopicsExceptionMultipleHandlersSynchronousModeInEnv()
236
240
$ this ->expectExceptionMessage ('Topic "customerDeleted" is configured for synchronous requests, that is why it must ' );
237
241
238
242
$ this ->getConfigInstance (
239
- __DIR__ . '/_files/valid_communication.xml ' ,
243
+ [ __DIR__ . '/_files/valid_communication.xml ' ] ,
240
244
__DIR__ . '/_files/communication_multiple_handlers_synchronous_mode.php '
241
245
)->getTopics ();
242
246
}
@@ -249,7 +253,7 @@ public function testGetTopicsExceptionInvalidRequestSchemaInEnv()
249
253
$ this ->expectExceptionMessage ('Request schema definition for topic "customerCreated" should reference existing service ' );
250
254
251
255
$ this ->getConfigInstance (
252
- __DIR__ . '/_files/valid_communication.xml ' ,
256
+ [ __DIR__ . '/_files/valid_communication.xml ' ] ,
253
257
__DIR__ . '/_files/communication_request_not_existing_service.php '
254
258
)->getTopics ();
255
259
}
@@ -262,7 +266,7 @@ public function testGetTopicsExceptionInvalidResponseSchemaInEnv()
262
266
$ this ->expectExceptionMessage ('Response schema definition for topic "customerCreated" should reference existing type o ' );
263
267
264
268
$ this ->getConfigInstance (
265
- __DIR__ . '/_files/valid_communication.xml ' ,
269
+ [ __DIR__ . '/_files/valid_communication.xml ' ] ,
266
270
__DIR__ . '/_files/communication_response_not_existing_service.php '
267
271
)->getTopics ();
268
272
}
@@ -275,7 +279,7 @@ public function testGetTopicsExceptionInvalidMethodInHandlerInEnv()
275
279
$ this ->expectExceptionMessage ('Service method specified in the definition of handler "customerCreatedFirst" for topic ' );
276
280
277
281
$ this ->getConfigInstance (
278
- __DIR__ . '/_files/valid_communication.xml ' ,
282
+ [ __DIR__ . '/_files/valid_communication.xml ' ] ,
279
283
__DIR__ . '/_files/communication_not_existing_handler_method.php '
280
284
)->getTopics ();
281
285
}
@@ -288,7 +292,7 @@ public function testGetTopicsExceptionWithDisabledHandlerInEnv()
288
292
$ this ->expectExceptionMessage ('Disabled handler "default" for topic "customerCreated" cannot be added to the config fi ' );
289
293
290
294
$ this ->getConfigInstance (
291
- __DIR__ . '/_files/valid_communication.xml ' ,
295
+ [ __DIR__ . '/_files/valid_communication.xml ' ] ,
292
296
__DIR__ . '/_files/communication_with_disabled_handler.php '
293
297
)->getTopics ();
294
298
}
@@ -301,7 +305,7 @@ public function testGetTopicsExceptionIncorrectRequestSchemaTypeInEnv()
301
305
$ this ->expectExceptionMessage ('Request schema type for topic "customerCreated" must be "object_interface" or "service_ ' );
302
306
303
307
$ this ->getConfigInstance (
304
- __DIR__ . '/_files/valid_communication.xml ' ,
308
+ [ __DIR__ . '/_files/valid_communication.xml ' ] ,
305
309
__DIR__ . '/_files/communication_incorrect_request_schema_type.php '
306
310
)->getTopics ();
307
311
}
@@ -314,24 +318,28 @@ public function testGetTopicsExceptionIsNotBooleanTypeOfIsSynchronousInEnv()
314
318
$ this ->expectExceptionMessage ('The attribute "is_synchronous" for topic "customerCreated" should have the value of the ' );
315
319
316
320
$ this ->getConfigInstance (
317
- __DIR__ . '/_files/valid_communication.xml ' ,
321
+ [ __DIR__ . '/_files/valid_communication.xml ' ] ,
318
322
__DIR__ . '/_files/communication_is_synchronous_is_not_boolean.php '
319
323
)->getTopics ();
320
324
}
321
325
322
326
/**
323
327
* Create config instance initialized with configuration from $configFilePath
324
328
*
325
- * @param string $configFilePath
329
+ * @param array $configFilePaths
326
330
* @param string|null $envConfigFilePath
327
331
* @return \Magento\Framework\Communication\ConfigInterface
328
332
*/
329
- protected function getConfigInstance ($ configFilePath , $ envConfigFilePath = null )
333
+ protected function getConfigInstance ($ configFilePaths , $ envConfigFilePath = null )
330
334
{
331
335
$ fileResolver = $ this ->getMockForAbstractClass (\Magento \Framework \Config \FileResolverInterface::class);
336
+ $ fileResolverResult = [];
337
+ foreach ($ configFilePaths as $ configFilePath ) {
338
+ $ fileResolverResult [] = file_get_contents ($ configFilePath );
339
+ }
332
340
$ fileResolver ->expects ($ this ->any ())
333
341
->method ('get ' )
334
- ->willReturn ([ file_get_contents ( $ configFilePath )] );
342
+ ->willReturn ($ fileResolverResult );
335
343
$ objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
336
344
$ xmlReader = $ objectManager ->create (
337
345
\Magento \Framework \Communication \Config \Reader \XmlReader::class,
0 commit comments