Skip to content

Commit 445fdea

Browse files
committed
[BWC] Add getHost() method to ConnectionInterface
1 parent a0ddad1 commit 445fdea

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

src/Elasticsearch/Connections/ConnectionInterface.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ public function __construct($handler, $hostDetails, $connectionParams,
3737
*/
3838
public function getTransportSchema();
3939

40+
/**
41+
* Get the hostname for this connection
42+
*
43+
* @return string
44+
*/
45+
public function getHost();
46+
4047
/**
4148
* Check to see if this instance is marked as 'alive'
4249
*

tests/Elasticsearch/Tests/ClientTest.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,6 @@ public function testInlineHosts()
273273
$client = Elasticsearch\ClientBuilder::create()->setHosts([
274274
'localhost:9200'
275275
])->build();
276-
277-
// We're casting to Connection here, instead of ConnectionInterface
278-
// so we can access getHost() on Connection
279-
280-
/** @var Connection $host */
281276
$host = $client->transport->getConnection();
282277
$this->assertEquals("localhost:9200", $host->getHost());
283278
$this->assertEquals("http", $host->getTransportSchema());
@@ -286,23 +281,20 @@ public function testInlineHosts()
286281
$client = Elasticsearch\ClientBuilder::create()->setHosts([
287282
'http://localhost:9200'
288283
])->build();
289-
/** @var Connection $host */
290284
$host = $client->transport->getConnection();
291285
$this->assertEquals("localhost:9200", $host->getHost());
292286
$this->assertEquals("http", $host->getTransportSchema());
293287

294288
$client = Elasticsearch\ClientBuilder::create()->setHosts([
295289
'http://foo.com:9200'
296290
])->build();
297-
/** @var Connection $host */
298291
$host = $client->transport->getConnection();
299292
$this->assertEquals("foo.com:9200", $host->getHost());
300293
$this->assertEquals("http", $host->getTransportSchema());
301294

302295
$client = Elasticsearch\ClientBuilder::create()->setHosts([
303296
'https://foo.com:9200'
304297
])->build();
305-
/** @var Connection $host */
306298
$host = $client->transport->getConnection();
307299
$this->assertEquals("foo.com:9200", $host->getHost());
308300
$this->assertEquals("https", $host->getTransportSchema());
@@ -314,7 +306,6 @@ public function testInlineHosts()
314306
$client = Elasticsearch\ClientBuilder::create()->setHosts([
315307
'https://user:pass@foo.com:9200'
316308
])->build();
317-
/** @var Connection $host */
318309
$host = $client->transport->getConnection();
319310
$this->assertEquals("foo.com:9200", $host->getHost());
320311
$this->assertEquals("https", $host->getTransportSchema());
@@ -329,7 +320,6 @@ public function testExtendedHosts()
329320
'scheme' => 'http'
330321
]
331322
])->build();
332-
/** @var Connection $host */
333323
$host = $client->transport->getConnection();
334324
$this->assertEquals("localhost:9200", $host->getHost());
335325
$this->assertEquals("http", $host->getTransportSchema());
@@ -342,7 +332,6 @@ public function testExtendedHosts()
342332
'scheme' => 'http'
343333
]
344334
])->build();
345-
/** @var Connection $host */
346335
$host = $client->transport->getConnection();
347336
$this->assertEquals("foo.com:9200", $host->getHost());
348337
$this->assertEquals("http", $host->getTransportSchema());
@@ -355,7 +344,6 @@ public function testExtendedHosts()
355344
'scheme' => 'https'
356345
]
357346
])->build();
358-
/** @var Connection $host */
359347
$host = $client->transport->getConnection();
360348
$this->assertEquals("foo.com:9200", $host->getHost());
361349
$this->assertEquals("https", $host->getTransportSchema());
@@ -367,7 +355,6 @@ public function testExtendedHosts()
367355
'scheme' => 'http'
368356
]
369357
])->build();
370-
/** @var Connection $host */
371358
$host = $client->transport->getConnection();
372359
$this->assertEquals("foo.com:9200", $host->getHost());
373360
$this->assertEquals("http", $host->getTransportSchema());
@@ -378,7 +365,6 @@ public function testExtendedHosts()
378365
'host' => 'foo.com'
379366
]
380367
])->build();
381-
/** @var Connection $host */
382368
$host = $client->transport->getConnection();
383369
$this->assertEquals("foo.com:9200", $host->getHost());
384370
$this->assertEquals("http", $host->getTransportSchema());
@@ -391,7 +377,6 @@ public function testExtendedHosts()
391377
'scheme' => 'https'
392378
]
393379
])->build();
394-
/** @var Connection $host */
395380
$host = $client->transport->getConnection();
396381
$this->assertEquals("foo.com:9500", $host->getHost());
397382
$this->assertEquals("https", $host->getTransportSchema());
@@ -415,7 +400,6 @@ public function testExtendedHosts()
415400
'host' => 'the_foo.com'
416401
]
417402
])->build();
418-
/** @var Connection $host */
419403
$host = $client->transport->getConnection();
420404
$this->assertEquals("the_foo.com:9200", $host->getHost());
421405
$this->assertEquals("http", $host->getTransportSchema());
@@ -429,7 +413,6 @@ public function testExtendedHosts()
429413
'pass' => 'abc#$%!abc'
430414
]
431415
])->build();
432-
/** @var Connection $host */
433416
$host = $client->transport->getConnection();
434417
$this->assertEquals("foo.com:9200", $host->getHost());
435418
$this->assertEquals("http", $host->getTransportSchema());

0 commit comments

Comments
 (0)