@@ -88,8 +88,12 @@ public function testGetVersion(array $esRelationship, string $esConfiguration, s
88
88
$ responseMock = $ this ->createMock (Response::class);
89
89
$ streamMock = $ this ->getMockForAbstractClass (StreamInterface::class);
90
90
91
- $ this ->environmentMock ->method ('getRelationship ' )
91
+ $ this ->environmentMock ->expects ($ this ->any ())
92
+ ->method ('getRelationship ' )
92
93
->willReturn ($ esRelationship );
94
+ $ this ->clientFactoryMock ->expects ($ this ->once ())
95
+ ->method ('create ' )
96
+ ->willReturn ($ clientMock );
93
97
$ clientMock ->expects ($ this ->once ())
94
98
->method ('get ' )
95
99
->with ($ esConfig ['host ' ] . ': ' . $ esConfig ['port ' ])
@@ -100,9 +104,6 @@ public function testGetVersion(array $esRelationship, string $esConfiguration, s
100
104
$ streamMock ->expects ($ this ->once ())
101
105
->method ('getContents ' )
102
106
->willReturn ($ esConfiguration );
103
- $ this ->clientFactoryMock ->expects ($ this ->once ())
104
- ->method ('create ' )
105
- ->willReturn ($ clientMock );
106
107
$ this ->loggerMock ->expects ($ this ->never ())
107
108
->method ('warning ' );
108
109
@@ -155,6 +156,48 @@ public function getVersionDataProvider(): array
155
156
];
156
157
}
157
158
159
+ /**
160
+ * @param array $esRelationship
161
+ * @param string $expectedVersion
162
+ * @throws ServiceException
163
+ *
164
+ * @dataProvider getVersionFromTypeDataProvider
165
+ */
166
+ public function testGetVersionFromType ($ esRelationship , $ expectedVersion )
167
+ {
168
+ $ this ->environmentMock ->expects ($ this ->any ())
169
+ ->method ('getRelationship ' )
170
+ ->willReturn ($ esRelationship );
171
+
172
+ $ this ->clientFactoryMock ->expects ($ this ->never ())
173
+ ->method ('create ' );
174
+
175
+ $ this ->assertSame ($ expectedVersion , $ this ->elasticSearch ->getVersion ());
176
+ }
177
+
178
+ public function getVersionFromTypeDataProvider ()
179
+ {
180
+ return [
181
+ [
182
+ [],
183
+ '0 '
184
+ ],
185
+ [
186
+ [
187
+ ['host ' => '127.0.0.1 ' , 'port ' => '1234 ' , 'type ' => 'elasticsearch:7.7 ' ]
188
+ ],
189
+ '7.7 '
190
+ ],
191
+ [
192
+ [
193
+ ['host ' => '127.0.0.1 ' , 'port ' => '1234 ' , 'type ' => 'elasticsearch:5.2 ' ]
194
+ ],
195
+ '5.2 '
196
+ ],
197
+
198
+ ];
199
+ }
200
+
158
201
/**
159
202
* @param string $version
160
203
* @param string $expected
@@ -216,6 +259,10 @@ public function getFullVersionDataProvider(): array
216
259
[
217
260
'2.4 ' ,
218
261
'elasticsearch '
262
+ ],
263
+ [
264
+ '7.7 ' ,
265
+ 'elasticsearch7 '
219
266
]
220
267
];
221
268
}
0 commit comments