Client set lib and version on connection (#1351)

* Added client metadata on server connection

* Added try...catch around server exception to supress CLIENT command errors

* Added exclusion for Relay connection

* Changed array index
This commit is contained in:
Vladyslav Vildanov
2023-08-02 09:42:01 +03:00
committed by GitHub
parent d8da27ba02
commit af236dc50a
6 changed files with 102 additions and 11 deletions
@@ -13,6 +13,7 @@
namespace Predis\Connection;
use PHPUnit\Framework\MockObject\MockObject;
use Predis\Client;
use Predis\Command\RawCommand;
use Predis\Response\Error as ErrorResponse;
@@ -196,6 +197,24 @@ class StreamConnectionTest extends PredisConnectionTestCase
$this->assertFalse($options['socket']['tcp_nodelay']);
}
/**
* @group connected
* @requiresRedisVersion < 7.0.0
*/
public function testConnectDoNotThrowsExceptionOnClientCommandError(): void
{
$connection = $this->createConnectionWithParams([]);
$connection->addConnectCommand(
new RawCommand('CLIENT', ['SETINFO', 'LIB-NAME', 'predis'])
);
$connection->addConnectCommand(
new RawCommand('CLIENT', ['SETINFO', 'LIB-VER', Client::VERSION])
);
$connection->connect();
$this->assertTrue(true);
}
/**
* @group disconnected
* @return void