mirror of
https://github.com/predis/predis.git
synced 2026-09-02 05:37:02 +00:00
Rename Predis\Connection\SingleConnectionInterface::pushInitCommand().
The new name is more explicit as it makes obvious that the commands added with it will be executed upon connect().
This commit is contained in:
@@ -30,7 +30,7 @@ abstract class AbstractConnection implements SingleConnectionInterface
|
||||
private $cachedId;
|
||||
|
||||
protected $parameters;
|
||||
protected $initCmds = array();
|
||||
protected $initCommands = array();
|
||||
|
||||
/**
|
||||
* @param ParametersInterface $parameters Initialization parameters for the connection.
|
||||
@@ -107,9 +107,9 @@ abstract class AbstractConnection implements SingleConnectionInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function pushInitCommand(CommandInterface $command)
|
||||
public function addConnectCommand(CommandInterface $command)
|
||||
{
|
||||
$this->initCmds[] = $command;
|
||||
$this->initCommands[] = $command;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,6 +211,6 @@ abstract class AbstractConnection implements SingleConnectionInterface
|
||||
*/
|
||||
public function __sleep()
|
||||
{
|
||||
return array('parameters', 'initCmds');
|
||||
return array('parameters', 'initCommands');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,13 +123,15 @@ class Factory implements FactoryInterface
|
||||
$parameters = $connection->getParameters();
|
||||
|
||||
if (isset($parameters->password)) {
|
||||
$command = new Command\RawCommand(array('AUTH', $parameters->password));
|
||||
$connection->pushInitCommand($command);
|
||||
$connection->addConnectCommand(
|
||||
new Command\RawCommand(array('AUTH', $parameters->password))
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($parameters->database)) {
|
||||
$command = new Command\RawCommand(array('SELECT', $parameters->database));
|
||||
$connection->pushInitCommand($command);
|
||||
$connection->addConnectCommand(
|
||||
new Command\RawCommand(array('SELECT', $parameters->database))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,8 +299,8 @@ class PhpiredisSocketConnection extends AbstractConnection
|
||||
|
||||
$this->connectWithTimeout($this->parameters);
|
||||
|
||||
if ($this->initCmds) {
|
||||
foreach ($this->initCmds as $command) {
|
||||
if ($this->initCommands) {
|
||||
foreach ($this->initCommands as $command) {
|
||||
$this->executeCommand($command);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ interface SingleConnectionInterface extends ConnectionInterface
|
||||
*
|
||||
* @param CommandInterface $command Instance of a Redis command.
|
||||
*/
|
||||
public function pushInitCommand(CommandInterface $command);
|
||||
public function addConnectCommand(CommandInterface $command);
|
||||
|
||||
/**
|
||||
* Reads a response from the server.
|
||||
|
||||
@@ -130,8 +130,8 @@ class StreamConnection extends AbstractConnection
|
||||
{
|
||||
parent::connect();
|
||||
|
||||
if ($this->initCmds) {
|
||||
foreach ($this->initCmds as $command) {
|
||||
if ($this->initCommands) {
|
||||
foreach ($this->initCommands as $command) {
|
||||
$this->executeCommand($command);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@ class WebdisConnection implements SingleConnectionInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function pushInitCommand(CommandInterface $command)
|
||||
public function addConnectCommand(CommandInterface $command)
|
||||
{
|
||||
$this->throwNotSupportedException(__FUNCTION__);
|
||||
}
|
||||
|
||||
@@ -198,8 +198,8 @@ abstract class PredisConnectionTestCase extends PredisTestCase
|
||||
->method('getArguments')
|
||||
->will($this->returnValue(array('ECHOED')));
|
||||
|
||||
$connection->pushInitCommand($cmdPing);
|
||||
$connection->pushInitCommand($cmdEcho);
|
||||
$connection->addConnectCommand($cmdPing);
|
||||
$connection->addConnectCommand($cmdEcho);
|
||||
|
||||
$connection->connect();
|
||||
}
|
||||
|
||||
@@ -111,8 +111,13 @@ class ComposableStreamConnectionTest extends PredisConnectionTestCase
|
||||
$connection = new ComposableStreamConnection($parameters);
|
||||
|
||||
if ($initialize) {
|
||||
$connection->pushInitCommand($profile->createCommand('select', array($parameters->database)));
|
||||
$connection->pushInitCommand($profile->createCommand('flushdb'));
|
||||
$connection->addConnectCommand(
|
||||
$profile->createCommand('select', array($parameters->database))
|
||||
);
|
||||
|
||||
$connection->addConnectCommand(
|
||||
$profile->createCommand('flushdb')
|
||||
);
|
||||
}
|
||||
|
||||
return $connection;
|
||||
|
||||
@@ -139,10 +139,10 @@ class FactoryTest extends PredisTestCase
|
||||
->method('getParameters')
|
||||
->will($this->returnValue($parameters));
|
||||
$connection->expects($this->at(1))
|
||||
->method('pushInitCommand')
|
||||
->method('addConnectCommand')
|
||||
->with($this->isRedisCommand('AUTH', array('foobar')));
|
||||
$connection->expects($this->at(2))
|
||||
->method('pushInitCommand')
|
||||
->method('addConnectCommand')
|
||||
->with($this->isRedisCommand('SELECT', array(0)));
|
||||
|
||||
$factory = new Factory();
|
||||
|
||||
@@ -117,8 +117,13 @@ class PhpiredisSocketConnectionTest extends PredisConnectionTestCase
|
||||
$connection = new PhpiredisSocketConnection($parameters);
|
||||
|
||||
if ($initialize) {
|
||||
$connection->pushInitCommand($profile->createCommand('select', array($parameters->database)));
|
||||
$connection->pushInitCommand($profile->createCommand('flushdb'));
|
||||
$connection->addConnectCommand(
|
||||
$profile->createCommand('select', array($parameters->database))
|
||||
);
|
||||
|
||||
$connection->addConnectCommand(
|
||||
$profile->createCommand('flushdb')
|
||||
);
|
||||
}
|
||||
|
||||
return $connection;
|
||||
|
||||
@@ -136,8 +136,13 @@ class PhpiredisStreamConnectionTest extends PredisConnectionTestCase
|
||||
$connection = new PhpiredisStreamConnection($parameters);
|
||||
|
||||
if ($initialize) {
|
||||
$connection->pushInitCommand($profile->createCommand('select', array($parameters->database)));
|
||||
$connection->pushInitCommand($profile->createCommand('flushdb'));
|
||||
$connection->addConnectCommand(
|
||||
$profile->createCommand('select', array($parameters->database))
|
||||
);
|
||||
|
||||
$connection->addConnectCommand(
|
||||
$profile->createCommand('flushdb')
|
||||
);
|
||||
}
|
||||
|
||||
return $connection;
|
||||
|
||||
@@ -114,8 +114,13 @@ class StreamConnectionTest extends PredisConnectionTestCase
|
||||
$connection = new StreamConnection($parameters);
|
||||
|
||||
if ($initialize) {
|
||||
$connection->pushInitCommand($profile->createCommand('select', array($parameters->database)));
|
||||
$connection->pushInitCommand($profile->createCommand('flushdb'));
|
||||
$connection->addConnectCommand(
|
||||
$profile->createCommand('select', array($parameters->database))
|
||||
);
|
||||
|
||||
$connection->addConnectCommand(
|
||||
$profile->createCommand('flushdb')
|
||||
);
|
||||
}
|
||||
|
||||
return $connection;
|
||||
|
||||
@@ -68,12 +68,13 @@ class WebdisConnectionTest extends PredisTestCase
|
||||
/**
|
||||
* @group disconnected
|
||||
* @expectedException Predis\NotSupportedException
|
||||
* @expectedExceptionMessage The method Predis\Connection\WebdisConnection::pushInitCommand() is not supported
|
||||
* @expectedExceptionMessage The method Predis\Connection\WebdisConnection::addConnectCommand() is not supported
|
||||
*
|
||||
*/
|
||||
public function testPushingInitCommandsIsNotSupported()
|
||||
public function testAddingConnectCommandsIsNotSupported()
|
||||
{
|
||||
$connection = new WebdisConnection($this->getParameters());
|
||||
$connection->pushInitCommand($this->getProfile()->createCommand('ping'));
|
||||
$connection->addConnectCommand($this->getProfile()->createCommand('ping'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user