Skip to content

Commit

Permalink
Use constants for default port and default host
Browse files Browse the repository at this point in the history
  • Loading branch information
ruflin committed May 16, 2015
1 parent 0a22982 commit fab4b57
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions test/lib/Elastica/Test/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Elastica\Test;

use Elastica\Client;
use Elastica\Connection;
use Elastica\Index;

class Base extends \PHPUnit_Framework_TestCase
Expand All @@ -16,7 +17,7 @@ protected function _getClient(array $params = array(), $callback = null)
{
$config = array(
'host' => $this->_getHost(),
'port' => getenv('ES_PORT') ?: 9200,
'port' => $this->_getPort(),
);

$config = array_merge($config, $params);
Expand All @@ -25,11 +26,19 @@ protected function _getClient(array $params = array(), $callback = null)
}

/**
* @return string Returns es host for tests
* @return string Host to es for elastica tests
*/
protected function _getHost()
{
return getenv('ES_HOST') ?: 'localhost';
return getenv('ES_HOST') ?: Connection::DEFAULT_HOST;
}

/**
* @return int Port to es for elastica tests
*/
protected function _getPort()
{
return getenv('ES_PORT') ?: Connection::DEFAULT_PORT;
}

/**
Expand Down

0 comments on commit fab4b57

Please sign in to comment.