File tree Expand file tree Collapse file tree 2 files changed +39
-8
lines changed
Process/Deploy/InstallUpdate/ConfigUpdate
Test/Unit/Process/Deploy/InstallUpdate/ConfigUpdate Expand file tree Collapse file tree 2 files changed +39
-8
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,13 @@ class Amqp implements ProcessInterface
33
33
*/
34
34
private $ configReader ;
35
35
36
+ /**
37
+ * Possible names for amqp relationship
38
+ *
39
+ * @var array
40
+ */
41
+ private $ possibleRelationshipNames = ['rabbitmq ' , 'mq ' , 'amqp ' ];
42
+
36
43
/**
37
44
* @param Environment $environment
38
45
* @param ConfigReader $configReader
@@ -56,7 +63,7 @@ public function __construct(
56
63
*/
57
64
public function execute ()
58
65
{
59
- $ mqConfig = $ this ->environment -> getRelationship ( ' mq ' );
66
+ $ mqConfig = $ this ->getAmqpConfig ( );
60
67
$ config = $ this ->configReader ->read ();
61
68
62
69
if (count ($ mqConfig )) {
@@ -95,4 +102,22 @@ private function removeAmqpConfig(array $config)
95
102
96
103
return $ config ;
97
104
}
105
+
106
+ /**
107
+ * Finds if configuration exists for one of possible amqp relationship names and return first match,
108
+ * amqp relationship can have different name on different environment.
109
+ *
110
+ * @return array
111
+ */
112
+ private function getAmqpConfig (): array
113
+ {
114
+ foreach ($ this ->possibleRelationshipNames as $ relationshipName ) {
115
+ $ mqConfig = $ this ->environment ->getRelationship ($ relationshipName );
116
+ if (!empty ($ mqConfig )) {
117
+ return $ mqConfig ;
118
+ }
119
+ }
120
+
121
+ return [];
122
+ }
98
123
}
Original file line number Diff line number Diff line change @@ -67,9 +67,9 @@ protected function setUp()
67
67
public function testExecuteWithoutAmqp ()
68
68
{
69
69
$ config = ['some config ' ];
70
- $ this ->environmentMock ->expects ($ this ->once ())
70
+ $ this ->environmentMock ->expects ($ this ->any ())
71
71
->method ('getRelationship ' )
72
- ->with (' mq ' )
72
+ ->with ($ this -> anything () )
73
73
->willReturn ([]);
74
74
$ this ->configReaderMock ->expects ($ this ->once ())
75
75
->method ('read ' )
@@ -110,10 +110,16 @@ public function testExecuteAddUpdate(array $config)
110
110
],
111
111
];
112
112
113
- $ this ->environmentMock ->expects ($ this ->once ( ))
113
+ $ this ->environmentMock ->expects ($ this ->exactly ( 2 ))
114
114
->method ('getRelationship ' )
115
- ->with ('mq ' )
116
- ->willReturn ($ amqpConfig );
115
+ ->withConsecutive (
116
+ ['rabbitmq ' ],
117
+ ['mq ' ]
118
+ )
119
+ ->willReturnOnConsecutiveCalls (
120
+ [],
121
+ $ amqpConfig
122
+ );
117
123
$ this ->configReaderMock ->expects ($ this ->once ())
118
124
->method ('read ' )
119
125
->willReturn ($ config );
@@ -158,9 +164,9 @@ public function executeAddUpdateDataProvider(): array
158
164
*/
159
165
public function testExecuteRemoveAmqp (array $ config , array $ expectedConfig )
160
166
{
161
- $ this ->environmentMock ->expects ($ this ->once ())
167
+ $ this ->environmentMock ->expects ($ this ->any ())
162
168
->method ('getRelationship ' )
163
- ->with (' mq ' )
169
+ ->with ($ this -> anything () )
164
170
->willReturn ([]);
165
171
$ this ->configReaderMock ->expects ($ this ->once ())
166
172
->method ('read ' )
You can’t perform that action at this time.
0 commit comments