diff --git a/lib/Predis/Connection/AbstractConnection.php b/lib/Predis/Connection/AbstractConnection.php index e47e9cdf..43269c0c 100644 --- a/lib/Predis/Connection/AbstractConnection.php +++ b/lib/Predis/Connection/AbstractConnection.php @@ -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'); } } diff --git a/lib/Predis/Connection/Factory.php b/lib/Predis/Connection/Factory.php index 6728155b..57f3e7a1 100644 --- a/lib/Predis/Connection/Factory.php +++ b/lib/Predis/Connection/Factory.php @@ -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)) + ); } } } diff --git a/lib/Predis/Connection/PhpiredisSocketConnection.php b/lib/Predis/Connection/PhpiredisSocketConnection.php index 3acc2e71..e1a1713d 100644 --- a/lib/Predis/Connection/PhpiredisSocketConnection.php +++ b/lib/Predis/Connection/PhpiredisSocketConnection.php @@ -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); } } diff --git a/lib/Predis/Connection/SingleConnectionInterface.php b/lib/Predis/Connection/SingleConnectionInterface.php index 7deb83f0..b935ee19 100644 --- a/lib/Predis/Connection/SingleConnectionInterface.php +++ b/lib/Predis/Connection/SingleConnectionInterface.php @@ -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. diff --git a/lib/Predis/Connection/StreamConnection.php b/lib/Predis/Connection/StreamConnection.php index a09dd691..ea886f62 100644 --- a/lib/Predis/Connection/StreamConnection.php +++ b/lib/Predis/Connection/StreamConnection.php @@ -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); } } diff --git a/lib/Predis/Connection/WebdisConnection.php b/lib/Predis/Connection/WebdisConnection.php index 143cdd8a..ca46a1ce 100644 --- a/lib/Predis/Connection/WebdisConnection.php +++ b/lib/Predis/Connection/WebdisConnection.php @@ -296,7 +296,7 @@ class WebdisConnection implements SingleConnectionInterface /** * {@inheritdoc} */ - public function pushInitCommand(CommandInterface $command) + public function addConnectCommand(CommandInterface $command) { $this->throwNotSupportedException(__FUNCTION__); } diff --git a/tests/PHPUnit/PredisConnectionTestCase.php b/tests/PHPUnit/PredisConnectionTestCase.php index 73cae97a..432c6830 100644 --- a/tests/PHPUnit/PredisConnectionTestCase.php +++ b/tests/PHPUnit/PredisConnectionTestCase.php @@ -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(); } diff --git a/tests/Predis/Connection/ComposableStreamConnectionTest.php b/tests/Predis/Connection/ComposableStreamConnectionTest.php index 919e387c..71862d5f 100644 --- a/tests/Predis/Connection/ComposableStreamConnectionTest.php +++ b/tests/Predis/Connection/ComposableStreamConnectionTest.php @@ -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; diff --git a/tests/Predis/Connection/FactoryTest.php b/tests/Predis/Connection/FactoryTest.php index 51761649..282babd3 100644 --- a/tests/Predis/Connection/FactoryTest.php +++ b/tests/Predis/Connection/FactoryTest.php @@ -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(); diff --git a/tests/Predis/Connection/PhpiredisSocketConnectionTest.php b/tests/Predis/Connection/PhpiredisSocketConnectionTest.php index ba39a73b..cfa71713 100644 --- a/tests/Predis/Connection/PhpiredisSocketConnectionTest.php +++ b/tests/Predis/Connection/PhpiredisSocketConnectionTest.php @@ -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; diff --git a/tests/Predis/Connection/PhpiredisStreamConnectionTest.php b/tests/Predis/Connection/PhpiredisStreamConnectionTest.php index 554159bc..543ee4f8 100644 --- a/tests/Predis/Connection/PhpiredisStreamConnectionTest.php +++ b/tests/Predis/Connection/PhpiredisStreamConnectionTest.php @@ -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; diff --git a/tests/Predis/Connection/StreamConnectionTest.php b/tests/Predis/Connection/StreamConnectionTest.php index abb86378..609e34ec 100644 --- a/tests/Predis/Connection/StreamConnectionTest.php +++ b/tests/Predis/Connection/StreamConnectionTest.php @@ -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; diff --git a/tests/Predis/Connection/WebdisConnectionTest.php b/tests/Predis/Connection/WebdisConnectionTest.php index 76c91d29..295b406b 100644 --- a/tests/Predis/Connection/WebdisConnectionTest.php +++ b/tests/Predis/Connection/WebdisConnectionTest.php @@ -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')); } /**