Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2185 Follow up on dependency lib version needed #2186

Merged
merged 4 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"require": {
"php": "~8.0.0 || ~8.1.0 || ~8.2.0",
"ext-json": "*",
"elastic/transport": "^8.8",
"elasticsearch/elasticsearch": "^8.11",
"elastic/transport": "^8.4",
"elasticsearch/elasticsearch": "^8.4.1",
"guzzlehttp/psr7": "^2.0",
"nyholm/dsn": "^2.0.0",
"psr/log": "^1.0 || ^2.0 || ^3.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ protected function _buildTransport(array $config): Transport
'scheme' => $config['schema'] ?? 'http',
'host' => $config['host'] ?? Connection::DEFAULT_HOST,
'port' => $config['port'] ?? Connection::DEFAULT_PORT,
'path' => isset($config['path']) ? \ltrim($config['path'], '/') : '',
'path' => isset($config['path']) ? '/'.\ltrim($config['path'], '/') : '',
]),
];
}
Expand Down
16 changes: 0 additions & 16 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,6 @@ public function getTransportObject(): Transport
return $this->getTransport();
}

/**
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This goes away because it is not supported anymore?

* @return bool Returns true if connection is persistent. True by default
*/
public function isPersistent()
{
return (bool) $this->hasParam('persistent') ? $this->getParam('persistent') : true;
}

/**
* @return $this
*/
Expand Down Expand Up @@ -267,12 +259,4 @@ public function getPassword()
{
return $this->hasParam('password') ? $this->getParam('password') : null;
}

/**
* @return string AuthType
*/
public function getAuthType()
{
return $this->hasParam('auth_type') ? \strtolower($this->getParam('auth_type')) : null;
}
}
4 changes: 2 additions & 2 deletions tests/ClientConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function testFromEmptyArray(): void
'port' => null,
'path' => null,
'url' => null,
'connections' => [], // host, port, path, timeout, transport, compression, persistent, timeout, username, password, config -> (curl, headers, url)
'connections' => [], // host, port, path, timeout, transport, compression, timeout, username, password, config -> (curl, headers, url)
'roundRobin' => false,
'retryOnConflict' => 0,
'username' => null,
Expand All @@ -124,7 +124,7 @@ public function testFromArray(): void
'port' => null,
'path' => null,
'url' => null,
'connections' => [], // host, port, path, timeout, transport, compression, persistent, timeout, username, password, config -> (curl, headers, url)
'connections' => [], // host, port, path, timeout, transport, compression, timeout, username, password, config -> (curl, headers, url)
'roundRobin' => false,
'retryOnConflict' => 0,
'username' => 'Jdoe',
Expand Down
58 changes: 58 additions & 0 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ public function testGetConfig(): void
$connection = new Connection(['config' => ['url' => $url]]);
$this->assertTrue($connection->hasConfig('url'));
$this->assertEquals($url, $connection->getConfig('url'));

$connection->setConfig([]);
$this->assertFalse($connection->hasConfig('url'));

$connection->addConfig('url', $url);
$this->assertTrue($connection->hasConfig('url'));
$this->assertEquals($url, $connection->getConfig('url'));
}

/**
Expand Down Expand Up @@ -154,4 +161,55 @@ public function testPasswordFromClient(): void

$this->assertEquals($password, $client->getConnection()->getPassword());
}

/**
* @group unit
*/
public function testPathFromClient(): void
{
$path = 'test';
$client = new Client(['path' => $path]);

$this->assertEquals($path, $client->getConnection()->getPath());

$changedPath = 'test2';

$client->getConnection()->setPath($changedPath);

$this->assertEquals($changedPath, $client->getConnection()->getPath());
}

/**
* @group unit
*/
public function testPortFromClient(): void
{
$port = 9000;
$client = new Client(['port' => $port]);

$this->assertEquals($port, $client->getConnection()->getPort());

$changedPort = 9001;

$client->getConnection()->setPort($changedPort);

$this->assertEquals($changedPort, $client->getConnection()->getPort());
}

/**
* @group unit
*/
public function testHostFromClient(): void
{
$host = 'localhost';
$client = new Client(['host' => $host]);

$this->assertEquals($host, $client->getConnection()->getHost());

$changedHost = 'localhostChanged';

$client->getConnection()->setHost($changedHost);

$this->assertEquals($changedHost, $client->getConnection()->getHost());
}
}
2 changes: 1 addition & 1 deletion tests/Query/MoreLikeThisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testSearch(): void
*/
public function testSearchByDocument(): void
{
$client = $this->_getClient(['persistent' => false]);
$client = $this->_getClient();
$index = $client->getIndex('elastica_test');
$index->create(
[
Expand Down
Loading