diff --git a/src/Elasticsearch/Connections/ConnectionInterface.php b/src/Elasticsearch/Connections/ConnectionInterface.php index 7e6038584..229000718 100644 --- a/src/Elasticsearch/Connections/ConnectionInterface.php +++ b/src/Elasticsearch/Connections/ConnectionInterface.php @@ -37,6 +37,13 @@ public function __construct($handler, $hostDetails, $connectionParams, */ public function getTransportSchema(); + /** + * Get the hostname for this connection + * + * @return string + */ + public function getHost(); + /** * Check to see if this instance is marked as 'alive' * diff --git a/tests/Elasticsearch/Tests/ClientTest.php b/tests/Elasticsearch/Tests/ClientTest.php index f89778d61..d73b3f16b 100644 --- a/tests/Elasticsearch/Tests/ClientTest.php +++ b/tests/Elasticsearch/Tests/ClientTest.php @@ -273,11 +273,6 @@ public function testInlineHosts() $client = Elasticsearch\ClientBuilder::create()->setHosts([ 'localhost:9200' ])->build(); - - // We're casting to Connection here, instead of ConnectionInterface - // so we can access getHost() on Connection - - /** @var Connection $host */ $host = $client->transport->getConnection(); $this->assertEquals("localhost:9200", $host->getHost()); $this->assertEquals("http", $host->getTransportSchema()); @@ -286,7 +281,6 @@ public function testInlineHosts() $client = Elasticsearch\ClientBuilder::create()->setHosts([ 'http://localhost:9200' ])->build(); - /** @var Connection $host */ $host = $client->transport->getConnection(); $this->assertEquals("localhost:9200", $host->getHost()); $this->assertEquals("http", $host->getTransportSchema()); @@ -294,7 +288,6 @@ public function testInlineHosts() $client = Elasticsearch\ClientBuilder::create()->setHosts([ 'http://foo.com:9200' ])->build(); - /** @var Connection $host */ $host = $client->transport->getConnection(); $this->assertEquals("foo.com:9200", $host->getHost()); $this->assertEquals("http", $host->getTransportSchema()); @@ -302,7 +295,6 @@ public function testInlineHosts() $client = Elasticsearch\ClientBuilder::create()->setHosts([ 'https://foo.com:9200' ])->build(); - /** @var Connection $host */ $host = $client->transport->getConnection(); $this->assertEquals("foo.com:9200", $host->getHost()); $this->assertEquals("https", $host->getTransportSchema()); @@ -314,7 +306,6 @@ public function testInlineHosts() $client = Elasticsearch\ClientBuilder::create()->setHosts([ 'https://user:pass@foo.com:9200' ])->build(); - /** @var Connection $host */ $host = $client->transport->getConnection(); $this->assertEquals("foo.com:9200", $host->getHost()); $this->assertEquals("https", $host->getTransportSchema()); @@ -329,7 +320,6 @@ public function testExtendedHosts() 'scheme' => 'http' ] ])->build(); - /** @var Connection $host */ $host = $client->transport->getConnection(); $this->assertEquals("localhost:9200", $host->getHost()); $this->assertEquals("http", $host->getTransportSchema()); @@ -342,7 +332,6 @@ public function testExtendedHosts() 'scheme' => 'http' ] ])->build(); - /** @var Connection $host */ $host = $client->transport->getConnection(); $this->assertEquals("foo.com:9200", $host->getHost()); $this->assertEquals("http", $host->getTransportSchema()); @@ -355,7 +344,6 @@ public function testExtendedHosts() 'scheme' => 'https' ] ])->build(); - /** @var Connection $host */ $host = $client->transport->getConnection(); $this->assertEquals("foo.com:9200", $host->getHost()); $this->assertEquals("https", $host->getTransportSchema()); @@ -367,7 +355,6 @@ public function testExtendedHosts() 'scheme' => 'http' ] ])->build(); - /** @var Connection $host */ $host = $client->transport->getConnection(); $this->assertEquals("foo.com:9200", $host->getHost()); $this->assertEquals("http", $host->getTransportSchema()); @@ -378,7 +365,6 @@ public function testExtendedHosts() 'host' => 'foo.com' ] ])->build(); - /** @var Connection $host */ $host = $client->transport->getConnection(); $this->assertEquals("foo.com:9200", $host->getHost()); $this->assertEquals("http", $host->getTransportSchema()); @@ -391,7 +377,6 @@ public function testExtendedHosts() 'scheme' => 'https' ] ])->build(); - /** @var Connection $host */ $host = $client->transport->getConnection(); $this->assertEquals("foo.com:9500", $host->getHost()); $this->assertEquals("https", $host->getTransportSchema()); @@ -415,7 +400,6 @@ public function testExtendedHosts() 'host' => 'the_foo.com' ] ])->build(); - /** @var Connection $host */ $host = $client->transport->getConnection(); $this->assertEquals("the_foo.com:9200", $host->getHost()); $this->assertEquals("http", $host->getTransportSchema()); @@ -429,7 +413,6 @@ public function testExtendedHosts() 'pass' => 'abc#$%!abc' ] ])->build(); - /** @var Connection $host */ $host = $client->transport->getConnection(); $this->assertEquals("foo.com:9200", $host->getHost()); $this->assertEquals("http", $host->getTransportSchema());