File tree Expand file tree Collapse file tree 2 files changed +37
-4
lines changed
lib/internal/Magento/Framework/MessageQueue
Config/Reader/Env/Converter
Test/Unit/Config/Reader/Env/Converter Expand file tree Collapse file tree 2 files changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ public function __construct(
27
27
}
28
28
29
29
/**
30
- * {@inheritDoc}
30
+ * @inheritdoc
31
31
*/
32
32
public function convert ($ source )
33
33
{
@@ -40,10 +40,12 @@ public function convert($source)
40
40
if (isset ($ configuration ['connections ' ])) {
41
41
$ publisherData = [];
42
42
foreach ($ configuration ['connections ' ] as $ connectionName => $ config ) {
43
- if (isset ($ this ->connectionToExchangeMap [$ connectionName ])) {
44
- $ publisherName = $ connectionName . '- ' . $ this ->connectionToExchangeMap [$ connectionName ];
43
+ $ exchange = $ config ['exchange ' ] ?? $ this ->connectionToExchangeMap [$ connectionName ] ?? null ;
44
+ if ($ exchange ) {
45
+ $ publisherName = $ connectionName . '- ' . $ exchange ;
45
46
$ config ['connection ' ] = $ config ['name ' ];
46
47
$ config ['name ' ] = $ publisherName ;
48
+ $ config ['exchange ' ] = $ exchange ;
47
49
$ publisherData [$ publisherName ] = $ config ;
48
50
$ connections = array_replace_recursive ($ connections , $ publisherData );
49
51
}
Original file line number Diff line number Diff line change @@ -32,10 +32,41 @@ protected function setUp(): void
32
32
public function testConvert ()
33
33
{
34
34
$ source = include __DIR__ . '/../../../../_files/env_2_2.php ' ;
35
+ $ expectedConfig = [
36
+ 'amqp-magento-db ' => [
37
+ 'name ' => 'amqp-magento-db ' ,
38
+ 'exchange ' => 'magento-db ' ,
39
+ 'connection ' =>'db '
40
+ ]
41
+ ];
42
+ $ actualResult = $ this ->converter ->convert ($ source ['config ' ]);
43
+ $ this ->assertEquals ($ expectedConfig , $ actualResult [ReaderEnv::ENV_PUBLISHERS ]);
44
+ }
45
+
46
+ public function testConvertUndefinedExchange ()
47
+ {
48
+ $ source = [
49
+ 'config ' => [
50
+ 'publishers ' => [
51
+ 'inventory.counter.updated ' => [
52
+ 'connections ' => [
53
+ 'amqp ' => [
54
+ 'name ' => 'db ' ,
55
+ ],
56
+ ]
57
+ ]
58
+ ],
59
+ 'consumers ' => [
60
+ 'inventoryQtyCounter ' => [
61
+ 'connection ' => 'db '
62
+ ]
63
+ ]
64
+ ]
65
+ ];
35
66
$ expectedConfig = [
36
67
'amqp-magento ' => [
37
68
'name ' => 'amqp-magento ' ,
38
- 'exchange ' => 'magento-db ' ,
69
+ 'exchange ' => 'magento ' ,
39
70
'connection ' =>'db '
40
71
]
41
72
];
You can’t perform that action at this time.
0 commit comments