|
@@ -205,9 +205,9 @@ abstract class PredisConnectionTestCase extends PredisTestCase
|
|
public function testSendingCommandForcesConnection()
|
|
public function testSendingCommandForcesConnection()
|
|
{
|
|
{
|
|
$connection = $this->createConnection();
|
|
$connection = $this->createConnection();
|
|
- $profile = $this->getCurrentProfile();
|
|
|
|
|
|
+ $commands = $this->getCommandFactory();
|
|
|
|
|
|
- $cmdPing = $profile->createCommand('ping');
|
|
|
|
|
|
+ $cmdPing = $commands->createCommand('ping');
|
|
|
|
|
|
$this->assertEquals('PONG', $connection->executeCommand($cmdPing));
|
|
$this->assertEquals('PONG', $connection->executeCommand($cmdPing));
|
|
$this->assertTrue($connection->isConnected());
|
|
$this->assertTrue($connection->isConnected());
|
|
@@ -218,9 +218,9 @@ abstract class PredisConnectionTestCase extends PredisTestCase
|
|
*/
|
|
*/
|
|
public function testExecutesCommandOnServer()
|
|
public function testExecutesCommandOnServer()
|
|
{
|
|
{
|
|
- $profile = $this->getCurrentProfile();
|
|
|
|
|
|
+ $commands = $this->getCommandFactory();
|
|
|
|
|
|
- $cmdPing = $this->getMock($profile->getCommandClass('ping'), array('parseResponse'));
|
|
|
|
|
|
+ $cmdPing = $this->getMock($commands->getCommandClass('ping'), array('parseResponse'));
|
|
$cmdPing->expects($this->never())
|
|
$cmdPing->expects($this->never())
|
|
->method('parseResponse');
|
|
->method('parseResponse');
|
|
|
|
|
|
@@ -234,8 +234,8 @@ abstract class PredisConnectionTestCase extends PredisTestCase
|
|
*/
|
|
*/
|
|
public function testExecutesCommandWithHolesInArguments()
|
|
public function testExecutesCommandWithHolesInArguments()
|
|
{
|
|
{
|
|
- $profile = $this->getCurrentProfile();
|
|
|
|
- $cmdDel = $profile->createCommand('mget', array(0 => 'key:0', 2 => 'key:2'));
|
|
|
|
|
|
+ $commands = $this->getCommandFactory();
|
|
|
|
+ $cmdDel = $commands->createCommand('mget', array(0 => 'key:0', 2 => 'key:2'));
|
|
|
|
|
|
$connection = $this->createConnection();
|
|
$connection = $this->createConnection();
|
|
|
|
|
|
@@ -247,13 +247,13 @@ abstract class PredisConnectionTestCase extends PredisTestCase
|
|
*/
|
|
*/
|
|
public function testExecutesMultipleCommandsOnServer()
|
|
public function testExecutesMultipleCommandsOnServer()
|
|
{
|
|
{
|
|
- $profile = $this->getCurrentProfile();
|
|
|
|
|
|
+ $commands = $this->getCommandFactory();
|
|
|
|
|
|
- $cmdPing = $profile->createCommand('ping');
|
|
|
|
- $cmdEcho = $profile->createCommand('echo', array('echoed'));
|
|
|
|
- $cmdGet = $profile->createCommand('get', array('foobar'));
|
|
|
|
- $cmdRpush = $profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol'));
|
|
|
|
- $cmdLrange = $profile->createCommand('lrange', array('metavars', 0, -1));
|
|
|
|
|
|
+ $cmdPing = $commands->createCommand('ping');
|
|
|
|
+ $cmdEcho = $commands->createCommand('echo', array('echoed'));
|
|
|
|
+ $cmdGet = $commands->createCommand('get', array('foobar'));
|
|
|
|
+ $cmdRpush = $commands->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol'));
|
|
|
|
+ $cmdLrange = $commands->createCommand('lrange', array('metavars', 0, -1));
|
|
|
|
|
|
$connection = $this->createConnection(true);
|
|
$connection = $this->createConnection(true);
|
|
|
|
|
|
@@ -269,9 +269,9 @@ abstract class PredisConnectionTestCase extends PredisTestCase
|
|
*/
|
|
*/
|
|
public function testWritesCommandToServer()
|
|
public function testWritesCommandToServer()
|
|
{
|
|
{
|
|
- $profile = $this->getCurrentProfile();
|
|
|
|
|
|
+ $commands = $this->getCommandFactory();
|
|
|
|
|
|
- $cmdEcho = $this->getMock($profile->getCommandClass('echo'), array('parseResponse'));
|
|
|
|
|
|
+ $cmdEcho = $this->getMock($commands->getCommandClass('echo'), array('parseResponse'));
|
|
$cmdEcho->setArguments(array('ECHOED'));
|
|
$cmdEcho->setArguments(array('ECHOED'));
|
|
$cmdEcho->expects($this->never())
|
|
$cmdEcho->expects($this->never())
|
|
->method('parseResponse');
|
|
->method('parseResponse');
|
|
@@ -286,9 +286,9 @@ abstract class PredisConnectionTestCase extends PredisTestCase
|
|
*/
|
|
*/
|
|
public function testReadsCommandFromServer()
|
|
public function testReadsCommandFromServer()
|
|
{
|
|
{
|
|
- $profile = $this->getCurrentProfile();
|
|
|
|
|
|
+ $commands = $this->getCommandFactory();
|
|
|
|
|
|
- $cmdEcho = $this->getMock($profile->getCommandClass('echo'), array('parseResponse'));
|
|
|
|
|
|
+ $cmdEcho = $this->getMock($commands->getCommandClass('echo'), array('parseResponse'));
|
|
$cmdEcho->setArguments(array('ECHOED'));
|
|
$cmdEcho->setArguments(array('ECHOED'));
|
|
$cmdEcho->expects($this->never())
|
|
$cmdEcho->expects($this->never())
|
|
->method('parseResponse');
|
|
->method('parseResponse');
|
|
@@ -304,13 +304,13 @@ abstract class PredisConnectionTestCase extends PredisTestCase
|
|
*/
|
|
*/
|
|
public function testIsAbleToWriteMultipleCommandsAndReadThemBackForPipelining()
|
|
public function testIsAbleToWriteMultipleCommandsAndReadThemBackForPipelining()
|
|
{
|
|
{
|
|
- $profile = $this->getCurrentProfile();
|
|
|
|
|
|
+ $commands = $this->getCommandFactory();
|
|
|
|
|
|
- $cmdPing = $this->getMock($profile->getCommandClass('ping'), array('parseResponse'));
|
|
|
|
|
|
+ $cmdPing = $this->getMock($commands->getCommandClass('ping'), array('parseResponse'));
|
|
$cmdPing->expects($this->never())
|
|
$cmdPing->expects($this->never())
|
|
->method('parseResponse');
|
|
->method('parseResponse');
|
|
|
|
|
|
- $cmdEcho = $this->getMock($profile->getCommandClass('echo'), array('parseResponse'));
|
|
|
|
|
|
+ $cmdEcho = $this->getMock($commands->getCommandClass('echo'), array('parseResponse'));
|
|
$cmdEcho->setArguments(array('ECHOED'));
|
|
$cmdEcho->setArguments(array('ECHOED'));
|
|
$cmdEcho->expects($this->never())
|
|
$cmdEcho->expects($this->never())
|
|
->method('parseResponse');
|
|
->method('parseResponse');
|
|
@@ -329,14 +329,14 @@ abstract class PredisConnectionTestCase extends PredisTestCase
|
|
*/
|
|
*/
|
|
public function testSendsInitializationCommandsOnConnection()
|
|
public function testSendsInitializationCommandsOnConnection()
|
|
{
|
|
{
|
|
- $profile = $this->getCurrentProfile();
|
|
|
|
|
|
+ $commands = $this->getCommandFactory();
|
|
|
|
|
|
- $cmdPing = $this->getMock($profile->getCommandClass('ping'), array('getArguments'));
|
|
|
|
|
|
+ $cmdPing = $this->getMock($commands->getCommandClass('ping'), array('getArguments'));
|
|
$cmdPing->expects($this->once())
|
|
$cmdPing->expects($this->once())
|
|
->method('getArguments')
|
|
->method('getArguments')
|
|
->will($this->returnValue(array()));
|
|
->will($this->returnValue(array()));
|
|
|
|
|
|
- $cmdEcho = $this->getMock($profile->getCommandClass('echo'), array('getArguments'));
|
|
|
|
|
|
+ $cmdEcho = $this->getMock($commands->getCommandClass('echo'), array('getArguments'));
|
|
$cmdEcho->expects($this->once())
|
|
$cmdEcho->expects($this->once())
|
|
->method('getArguments')
|
|
->method('getArguments')
|
|
->will($this->returnValue(array('ECHOED')));
|
|
->will($this->returnValue(array('ECHOED')));
|
|
@@ -353,17 +353,17 @@ abstract class PredisConnectionTestCase extends PredisTestCase
|
|
*/
|
|
*/
|
|
public function testReadsStatusResponses()
|
|
public function testReadsStatusResponses()
|
|
{
|
|
{
|
|
- $profile = $this->getCurrentProfile();
|
|
|
|
|
|
+ $commands = $this->getCommandFactory();
|
|
$connection = $this->createConnection(true);
|
|
$connection = $this->createConnection(true);
|
|
|
|
|
|
- $connection->writeRequest($profile->createCommand('set', array('foo', 'bar')));
|
|
|
|
|
|
+ $connection->writeRequest($commands->createCommand('set', array('foo', 'bar')));
|
|
$this->assertInstanceOf('Predis\Response\Status', $connection->read());
|
|
$this->assertInstanceOf('Predis\Response\Status', $connection->read());
|
|
|
|
|
|
- $connection->writeRequest($profile->createCommand('ping'));
|
|
|
|
|
|
+ $connection->writeRequest($commands->createCommand('ping'));
|
|
$this->assertInstanceOf('Predis\Response\Status', $connection->read());
|
|
$this->assertInstanceOf('Predis\Response\Status', $connection->read());
|
|
|
|
|
|
- $connection->writeRequest($profile->createCommand('multi'));
|
|
|
|
- $connection->writeRequest($profile->createCommand('ping'));
|
|
|
|
|
|
+ $connection->writeRequest($commands->createCommand('multi'));
|
|
|
|
+ $connection->writeRequest($commands->createCommand('ping'));
|
|
$this->assertInstanceOf('Predis\Response\Status', $connection->read());
|
|
$this->assertInstanceOf('Predis\Response\Status', $connection->read());
|
|
$this->assertInstanceOf('Predis\Response\Status', $connection->read());
|
|
$this->assertInstanceOf('Predis\Response\Status', $connection->read());
|
|
}
|
|
}
|
|
@@ -373,15 +373,15 @@ abstract class PredisConnectionTestCase extends PredisTestCase
|
|
*/
|
|
*/
|
|
public function testReadsBulkResponses()
|
|
public function testReadsBulkResponses()
|
|
{
|
|
{
|
|
- $profile = $this->getCurrentProfile();
|
|
|
|
|
|
+ $commands = $this->getCommandFactory();
|
|
$connection = $this->createConnection(true);
|
|
$connection = $this->createConnection(true);
|
|
|
|
|
|
- $connection->executeCommand($profile->createCommand('set', array('foo', 'bar')));
|
|
|
|
|
|
+ $connection->executeCommand($commands->createCommand('set', array('foo', 'bar')));
|
|
|
|
|
|
- $connection->writeRequest($profile->createCommand('get', array('foo')));
|
|
|
|
|
|
+ $connection->writeRequest($commands->createCommand('get', array('foo')));
|
|
$this->assertSame('bar', $connection->read());
|
|
$this->assertSame('bar', $connection->read());
|
|
|
|
|
|
- $connection->writeRequest($profile->createCommand('get', array('hoge')));
|
|
|
|
|
|
+ $connection->writeRequest($commands->createCommand('get', array('hoge')));
|
|
$this->assertNull($connection->read());
|
|
$this->assertNull($connection->read());
|
|
}
|
|
}
|
|
|
|
|
|
@@ -390,11 +390,11 @@ abstract class PredisConnectionTestCase extends PredisTestCase
|
|
*/
|
|
*/
|
|
public function testReadsIntegerResponses()
|
|
public function testReadsIntegerResponses()
|
|
{
|
|
{
|
|
- $profile = $this->getCurrentProfile();
|
|
|
|
|
|
+ $commands = $this->getCommandFactory();
|
|
$connection = $this->createConnection(true);
|
|
$connection = $this->createConnection(true);
|
|
|
|
|
|
- $connection->executeCommand($profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol')));
|
|
|
|
- $connection->writeRequest($profile->createCommand('llen', array('metavars')));
|
|
|
|
|
|
+ $connection->executeCommand($commands->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol')));
|
|
|
|
+ $connection->writeRequest($commands->createCommand('llen', array('metavars')));
|
|
|
|
|
|
$this->assertSame(3, $connection->read());
|
|
$this->assertSame(3, $connection->read());
|
|
}
|
|
}
|
|
@@ -404,11 +404,11 @@ abstract class PredisConnectionTestCase extends PredisTestCase
|
|
*/
|
|
*/
|
|
public function testReadsErrorResponsesAsResponseErrorObjects()
|
|
public function testReadsErrorResponsesAsResponseErrorObjects()
|
|
{
|
|
{
|
|
- $profile = $this->getCurrentProfile();
|
|
|
|
|
|
+ $commands = $this->getCommandFactory();
|
|
$connection = $this->createConnection(true);
|
|
$connection = $this->createConnection(true);
|
|
|
|
|
|
- $connection->executeCommand($profile->createCommand('set', array('foo', 'bar')));
|
|
|
|
- $connection->writeRequest($profile->createCommand('rpush', array('foo', 'baz')));
|
|
|
|
|
|
+ $connection->executeCommand($commands->createCommand('set', array('foo', 'bar')));
|
|
|
|
+ $connection->writeRequest($commands->createCommand('rpush', array('foo', 'baz')));
|
|
|
|
|
|
$this->assertInstanceOf('Predis\Response\Error', $error = $connection->read());
|
|
$this->assertInstanceOf('Predis\Response\Error', $error = $connection->read());
|
|
$this->assertRegExp('/[ERR|WRONGTYPE] Operation against a key holding the wrong kind of value/', $error->getMessage());
|
|
$this->assertRegExp('/[ERR|WRONGTYPE] Operation against a key holding the wrong kind of value/', $error->getMessage());
|
|
@@ -419,11 +419,11 @@ abstract class PredisConnectionTestCase extends PredisTestCase
|
|
*/
|
|
*/
|
|
public function testReadsMultibulkResponsesAsArrays()
|
|
public function testReadsMultibulkResponsesAsArrays()
|
|
{
|
|
{
|
|
- $profile = $this->getCurrentProfile();
|
|
|
|
|
|
+ $commands = $this->getCommandFactory();
|
|
$connection = $this->createConnection(true);
|
|
$connection = $this->createConnection(true);
|
|
|
|
|
|
- $connection->executeCommand($profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol')));
|
|
|
|
- $connection->writeRequest($profile->createCommand('lrange', array('metavars', 0, -1)));
|
|
|
|
|
|
+ $connection->executeCommand($commands->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol')));
|
|
|
|
+ $connection->writeRequest($commands->createCommand('lrange', array('metavars', 0, -1)));
|
|
|
|
|
|
$this->assertSame(array('foo', 'hoge', 'lol'), $connection->read());
|
|
$this->assertSame(array('foo', 'hoge', 'lol'), $connection->read());
|
|
}
|
|
}
|
|
@@ -499,13 +499,13 @@ abstract class PredisConnectionTestCase extends PredisTestCase
|
|
*/
|
|
*/
|
|
public function testThrowsExceptionOnReadWriteTimeout()
|
|
public function testThrowsExceptionOnReadWriteTimeout()
|
|
{
|
|
{
|
|
- $profile = $this->getCurrentProfile();
|
|
|
|
|
|
+ $commands = $this->getCommandFactory();
|
|
|
|
|
|
$connection = $this->createConnectionWithParams(array(
|
|
$connection = $this->createConnectionWithParams(array(
|
|
'read_write_timeout' => 0.5,
|
|
'read_write_timeout' => 0.5,
|
|
), true);
|
|
), true);
|
|
|
|
|
|
- $connection->executeCommand($profile->createCommand('brpop', array('foo', 3)));
|
|
|
|
|
|
+ $connection->executeCommand($commands->createCommand('brpop', array('foo', 3)));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -518,7 +518,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase
|
|
$connection = $this->createConnection();
|
|
$connection = $this->createConnection();
|
|
$stream = $connection->getResource();
|
|
$stream = $connection->getResource();
|
|
|
|
|
|
- $connection->writeRequest($this->getCurrentProfile()->createCommand('ping'));
|
|
|
|
|
|
+ $connection->writeRequest($this->getCommandFactory()->createCommand('ping'));
|
|
fread($stream, 1);
|
|
fread($stream, 1);
|
|
|
|
|
|
$connection->read();
|
|
$connection->read();
|
|
@@ -601,7 +601,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase
|
|
protected function createConnectionWithParams($parameters, $initialize = false)
|
|
protected function createConnectionWithParams($parameters, $initialize = false)
|
|
{
|
|
{
|
|
$class = static::CONNECTION_CLASS;
|
|
$class = static::CONNECTION_CLASS;
|
|
- $profile = $this->getCurrentProfile();
|
|
|
|
|
|
+ $commands = $this->getCommandFactory();
|
|
|
|
|
|
if (!$parameters instanceof ParametersInterface) {
|
|
if (!$parameters instanceof ParametersInterface) {
|
|
$parameters = $this->getParameters($parameters);
|
|
$parameters = $this->getParameters($parameters);
|
|
@@ -611,11 +611,11 @@ abstract class PredisConnectionTestCase extends PredisTestCase
|
|
|
|
|
|
if ($initialize) {
|
|
if ($initialize) {
|
|
$connection->addConnectCommand(
|
|
$connection->addConnectCommand(
|
|
- $profile->createCommand('select', array($parameters->database))
|
|
|
|
|
|
+ $commands->createCommand('select', array($parameters->database))
|
|
);
|
|
);
|
|
|
|
|
|
$connection->addConnectCommand(
|
|
$connection->addConnectCommand(
|
|
- $profile->createCommand('flushdb')
|
|
|
|
|
|
+ $commands->createCommand('flushdb')
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|