Client set name and version on connection (#1347)

* Added client metadata on server connection

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

* Added exclusion for Relay connection
This commit is contained in:
Vladyslav Vildanov
2023-08-03 09:04:04 +03:00
committed by GitHub
parent a3311d6869
commit 4172d2265f
6 changed files with 110 additions and 10 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;
@@ -195,4 +196,22 @@ class StreamConnectionTest extends PredisConnectionTestCase
$this->assertArrayHasKey('tcp_nodelay', $options['socket']);
$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);
}
}