|
@@ -63,6 +63,32 @@ class ServerClientTest extends CommandTestCase
|
|
|
$this->assertSame($expected, $command->getArguments());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @group disconnected
|
|
|
+ */
|
|
|
+ public function testFilterArgumentsOfClientGetname()
|
|
|
+ {
|
|
|
+ $arguments = $expected = array('getname');
|
|
|
+
|
|
|
+ $command = $this->getCommand();
|
|
|
+ $command->setArguments($arguments);
|
|
|
+
|
|
|
+ $this->assertSame($expected, $command->getArguments());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @group disconnected
|
|
|
+ */
|
|
|
+ public function testFilterArgumentsOfClientSetname()
|
|
|
+ {
|
|
|
+ $arguments = $expected = array('setname', 'connection-a');
|
|
|
+
|
|
|
+ $command = $this->getCommand();
|
|
|
+ $command->setArguments($arguments);
|
|
|
+
|
|
|
+ $this->assertSame($expected, $command->getArguments());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @group disconnected
|
|
|
*/
|
|
@@ -117,6 +143,55 @@ BUFFER;
|
|
|
$this->assertArrayHasKey('psub', $clients[0]);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @group connected
|
|
|
+ */
|
|
|
+ public function testGetsNameOfConnection()
|
|
|
+ {
|
|
|
+ $redis = $this->getClient();
|
|
|
+ $clientName = $redis->client('GETNAME');
|
|
|
+ $this->assertNull($clientName);
|
|
|
+
|
|
|
+ $expectedConnectionName = 'foo-bar';
|
|
|
+ $this->assertTrue($redis->client('SETNAME', $expectedConnectionName));
|
|
|
+ $this->assertEquals($expectedConnectionName, $redis->client('GETNAME'));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @group connected
|
|
|
+ */
|
|
|
+ public function testSetsNameOfConnection()
|
|
|
+ {
|
|
|
+ $redis = $this->getClient();
|
|
|
+
|
|
|
+ $expectedConnectionName = 'foo-baz';
|
|
|
+ $this->assertTrue($redis->client('SETNAME', $expectedConnectionName));
|
|
|
+ $this->assertEquals($expectedConnectionName, $redis->client('GETNAME'));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function invalidConnectionNameProvider()
|
|
|
+ {
|
|
|
+ return array(
|
|
|
+ array('foo space'),
|
|
|
+ array('foo \n'),
|
|
|
+ array('foo $'),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @group connected
|
|
|
+ * @expectedException Predis\ServerException
|
|
|
+ * @dataProvider invalidConnectionNameProvider
|
|
|
+ */
|
|
|
+ public function testInvalidSetNameOfConnection($invalidConnectionName)
|
|
|
+ {
|
|
|
+ $redis = $this->getClient();
|
|
|
+ $redis->client('SETNAME', $invalidConnectionName);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @group connected
|
|
|
* @expectedException Predis\ServerException
|