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(
2727 }
2828
2929 /**
30- * {@inheritDoc}
30+ * @inheritdoc
3131 */
3232 public function convert ($ source )
3333 {
@@ -40,10 +40,12 @@ public function convert($source)
4040 if (isset ($ configuration ['connections ' ])) {
4141 $ publisherData = [];
4242 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 ;
4546 $ config ['connection ' ] = $ config ['name ' ];
4647 $ config ['name ' ] = $ publisherName ;
48+ $ config ['exchange ' ] = $ exchange ;
4749 $ publisherData [$ publisherName ] = $ config ;
4850 $ connections = array_replace_recursive ($ connections , $ publisherData );
4951 }
Original file line number Diff line number Diff line change @@ -32,10 +32,41 @@ protected function setUp(): void
3232 public function testConvert ()
3333 {
3434 $ 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+ ];
3566 $ expectedConfig = [
3667 'amqp-magento ' => [
3768 'name ' => 'amqp-magento ' ,
38- 'exchange ' => 'magento-db ' ,
69+ 'exchange ' => 'magento ' ,
3970 'connection ' =>'db '
4071 ]
4172 ];
You can’t perform that action at this time.
0 commit comments