Skip to content

Commit

Permalink
[BWC] Add getHost() method to ConnectionInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
polyfractal committed Sep 12, 2016
1 parent a0ddad1 commit 445fdea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
7 changes: 7 additions & 0 deletions src/Elasticsearch/Connections/ConnectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
*
Expand Down
17 changes: 0 additions & 17 deletions tests/Elasticsearch/Tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -286,23 +281,20 @@ 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());

$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());

$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());
Expand All @@ -314,7 +306,6 @@ public function testInlineHosts()
$client = Elasticsearch\ClientBuilder::create()->setHosts([
'https://user:[email protected]:9200'
])->build();
/** @var Connection $host */
$host = $client->transport->getConnection();
$this->assertEquals("foo.com:9200", $host->getHost());
$this->assertEquals("https", $host->getTransportSchema());
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand Down

0 comments on commit 445fdea

Please sign in to comment.