Przeglądaj źródła

Merge branch 'v0.9/connection-namespace-1'

Daniele Alessandri 11 lat temu
rodzic
commit
e66c33a444
43 zmienionych plików z 221 dodań i 200 usunięć
  1. 17 14
      CHANGELOG.md
  2. 8 10
      lib/Predis/Client.php
  3. 3 4
      lib/Predis/Configuration/ConnectionFactoryOption.php
  4. 8 8
      lib/Predis/Connection/AbstractConnection.php
  5. 1 1
      lib/Predis/Connection/AggregateConnectionInterface.php
  6. 1 1
      lib/Predis/Connection/ClusterConnectionInterface.php
  7. 2 2
      lib/Predis/Connection/ComposableStreamConnection.php
  8. 10 8
      lib/Predis/Connection/Factory.php
  9. 3 3
      lib/Predis/Connection/FactoryInterface.php
  10. 2 2
      lib/Predis/Connection/Parameters.php
  11. 2 3
      lib/Predis/Connection/ParametersInterface.php
  12. 10 10
      lib/Predis/Connection/PhpiredisSocketConnection.php
  13. 1 1
      lib/Predis/Connection/PhpiredisStreamConnection.php
  14. 1 1
      lib/Predis/Connection/PredisCluster.php
  15. 3 3
      lib/Predis/Connection/RedisCluster.php
  16. 1 1
      lib/Predis/Connection/ReplicationConnectionInterface.php
  17. 2 2
      lib/Predis/Connection/SingleConnectionInterface.php
  18. 6 6
      lib/Predis/Connection/StreamConnection.php
  19. 7 7
      lib/Predis/Connection/WebdisConnection.php
  20. 3 3
      lib/Predis/Monitor/Consumer.php
  21. 3 3
      lib/Predis/PubSub/Consumer.php
  22. 4 4
      lib/Predis/Transaction/MultiExec.php
  23. 2 2
      tests/PHPUnit/PredisConnectionTestCase.php
  24. 2 2
      tests/PHPUnit/PredisTestCase.php
  25. 11 13
      tests/Predis/ClientTest.php
  26. 11 7
      tests/Predis/CommunicationExceptionTest.php
  27. 4 5
      tests/Predis/Configuration/ConnectionFactoryOptionTest.php
  28. 3 3
      tests/Predis/Configuration/OptionsTest.php
  29. 7 2
      tests/Predis/Connection/ComposableStreamConnectionTest.php
  30. 31 31
      tests/Predis/Connection/FactoryTest.php
  31. 1 1
      tests/Predis/Connection/MasterSlaveReplicationTest.php
  32. 17 17
      tests/Predis/Connection/ParametersTest.php
  33. 7 2
      tests/Predis/Connection/PhpiredisSocketConnectionTest.php
  34. 7 2
      tests/Predis/Connection/PhpiredisStreamConnectionTest.php
  35. 1 1
      tests/Predis/Connection/PredisClusterTest.php
  36. 5 5
      tests/Predis/Connection/RedisClusterTest.php
  37. 7 2
      tests/Predis/Connection/StreamConnectionTest.php
  38. 4 3
      tests/Predis/Connection/WebdisConnectionTest.php
  39. 1 1
      tests/Predis/Monitor/ConsumerTest.php
  40. 1 1
      tests/Predis/Pipeline/AtomicTest.php
  41. 1 1
      tests/Predis/PubSub/ConsumerTest.php
  42. 0 1
      tests/Predis/Response/Iterator/MultiBulkTest.php
  43. 0 1
      tests/Predis/Response/Iterator/MultiBulkTupleTest.php

+ 17 - 14
CHANGELOG.md

@@ -42,29 +42,32 @@ v0.9.0 (201x-xx-xx)
     - `fire-and-forget`: returns a pipeline that does not read back responses
       (class: `Predis\Pipeline\FireAndForget`).
 
-- The two base abstract command classes have been renamed in the following way:
+- Renamed the two base abstract command classes:
 
     - `Predis\Command\AbstractCommand` is now `Predis\Command\Command`
     - `Predis\Command\ScriptedCommand` is now `Predis\Command\ScriptCommand`
 
-- The method `Predis\Connection\ConnectionInterface::writeCommand()` has been
-  renamed to `writeRequest()` for consistency with its counterpart, the method
-  `readResponse()`.
+- Renamed `Predis\Connection\ConnectionInterface::writeCommand()` into
+  `writeRequest()` for consistency with its counterpart, `readResponse()`.
 
-- The connection based on ext-phpiredis and ext-socket has been renamed for the
-  sake of consistency to `Predis\Connection\PhpiredisSocketConnection`. The one
-  based on PHP's streams is still `Predis\Connection\PhpiredisStreamConnection`.
+- Renamed `Predis\Connection\SingleConnectionInterface::pushInitCommand()` into
+  `addConnectCommand()` which is more obvious.
 
-- The connection factory has been simplified and does not need anymore a profile
-  to create `AUTH` and `SELECT` commands when connection parameters contain both
-  `password` and `database`. Raw commands will be used instead.
+- Renamed the connection class based on both ext-phpiredis and ext-socket into
+  `Predis\Connection\PhpiredisSocketConnection`. The one based on PHP's streams
+  is still named `Predis\Connection\PhpiredisStreamConnection`.
 
-- `ConnectionParameters::__construct()` only accepts named arrays, but instances
-  can be created using URIs or arrays using the `ConnectionParameters::create()`
-  static method.
+- Renamed the connection factory class to `Predis\Connection\Factory`. Now its
+  constructor does not require anymore a profile instance to create `AUTH` and
+  `SELECT` commands when parameters contain both `password` and `database`. Raw
+  commands will be used instead.
+
+- Renamed the connection parameters class to `Predis\Connection\Parameters`. Now
+  its constructor accepts only named arrays, but instances can still be created
+  using both URIs or arrays using the static method `Parameters::create()`.
 
 - Most classes and interfaces in the `Predis\Protocol` namespace have been moved
-  or renamed while rationalizing the whole API of external protocol processors.
+  or renamed while rationalizing the whole API for external protocol processors.
 
 - All of the interfaces and classes related to translated Redis response types
   have been moved in the new `Predis\Response` namespace and most of them have

+ 8 - 10
lib/Predis/Client.php

@@ -17,9 +17,7 @@ use Predis\Command\CommandInterface;
 use Predis\Command\RawCommand;
 use Predis\Command\ScriptCommand;
 use Predis\Configuration;
-use Predis\Connection\AggregatedConnectionInterface;
-use Predis\Connection\ConnectionInterface;
-use Predis\Connection\ConnectionParametersInterface;
+use Predis\Connection;
 use Predis\Monitor;
 use Predis\Pipeline;
 use Predis\PubSub;
@@ -83,21 +81,21 @@ class Client implements ClientInterface
      * Accepted types for connection parameters are:
      *
      *  - Instance of Predis\Connection\ConnectionInterface.
-     *  - Instance of Predis\Connection\ConnectionParametersInterface.
+     *  - Instance of Predis\Connection\ParametersInterface.
      *  - Array
      *  - String
      *  - Callable
      *
      * @param mixed $parameters Connection parameters or connection instance.
-     * @return ConnectionInterface
+     * @return Connection\ConnectionInterface
      */
     protected function createConnection($parameters)
     {
-        if ($parameters instanceof ConnectionInterface) {
+        if ($parameters instanceof Connection\ConnectionInterface) {
             return $parameters;
         }
 
-        if ($parameters instanceof ConnectionParametersInterface || is_string($parameters)) {
+        if ($parameters instanceof Connection\ParametersInterface || is_string($parameters)) {
             return $this->options->connections->create($parameters);
         }
 
@@ -146,7 +144,7 @@ class Client implements ClientInterface
         return function () use ($callable) {
             $connection = call_user_func_array($callable, func_get_args());
 
-            if (!$connection instanceof ConnectionInterface) {
+            if (!$connection instanceof Connection\ConnectionInterface) {
                 throw new UnexpectedValueException(
                     'The callable connection initializer returned an invalid type'
                 );
@@ -242,9 +240,9 @@ class Client implements ClientInterface
      */
     public function getConnectionById($connectionID)
     {
-        if (!$this->connection instanceof AggregatedConnectionInterface) {
+        if (!$this->connection instanceof Connection\AggregateConnectionInterface) {
             throw new NotSupportedException(
-                'Retrieving connections by ID is supported only when using aggregated connections'
+                'Retrieving connections by ID is supported only when using aggregate connections'
             );
         }
 

+ 3 - 4
lib/Predis/Configuration/ConnectionFactoryOption.php

@@ -12,8 +12,7 @@
 namespace Predis\Configuration;
 
 use InvalidArgumentException;
-use Predis\Connection\ConnectionFactory;
-use Predis\Connection\ConnectionFactoryInterface;
+use Predis\Connection;
 
 /**
  * Configures a connection factory used by the client to create new connection
@@ -28,7 +27,7 @@ class ConnectionFactoryOption implements OptionInterface
      */
     public function filter(OptionsInterface $options, $value)
     {
-        if ($value instanceof ConnectionFactoryInterface) {
+        if ($value instanceof Connection\FactoryInterface) {
             return $value;
         } else if (is_array($value)) {
             $factory = $this->getDefault($options);
@@ -48,6 +47,6 @@ class ConnectionFactoryOption implements OptionInterface
      */
     public function getDefault(OptionsInterface $options)
     {
-        return new ConnectionFactory();
+        return new Connection\Factory();
     }
 }

+ 8 - 8
lib/Predis/Connection/AbstractConnection.php

@@ -30,12 +30,12 @@ abstract class AbstractConnection implements SingleConnectionInterface
     private $cachedId;
 
     protected $parameters;
-    protected $initCmds = array();
+    protected $initCommands = array();
 
     /**
-     * @param ConnectionParametersInterface $parameters Initialization parameters for the connection.
+     * @param ParametersInterface $parameters Initialization parameters for the connection.
      */
-    public function __construct(ConnectionParametersInterface $parameters)
+    public function __construct(ParametersInterface $parameters)
     {
         $this->parameters = $this->assertParameters($parameters);
     }
@@ -52,9 +52,9 @@ abstract class AbstractConnection implements SingleConnectionInterface
     /**
      * Checks some of the parameters used to initialize the connection.
      *
-     * @param ConnectionParametersInterface $parameters Initialization parameters for the connection.
+     * @param ParametersInterface $parameters Initialization parameters for the connection.
      */
-    protected function assertParameters(ConnectionParametersInterface $parameters)
+    protected function assertParameters(ParametersInterface $parameters)
     {
         $scheme = $parameters->scheme;
 
@@ -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');
     }
 }

+ 1 - 1
lib/Predis/Connection/AggregatedConnectionInterface.php → lib/Predis/Connection/AggregateConnectionInterface.php

@@ -19,7 +19,7 @@ use Predis\Command\CommandInterface;
  *
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-interface AggregatedConnectionInterface extends ConnectionInterface
+interface AggregateConnectionInterface extends ConnectionInterface
 {
     /**
      * Adds a connection instance to the aggregate connection.

+ 1 - 1
lib/Predis/Connection/ClusterConnectionInterface.php

@@ -17,6 +17,6 @@ namespace Predis\Connection;
  *
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-interface ClusterConnectionInterface extends AggregatedConnectionInterface
+interface ClusterConnectionInterface extends AggregateConnectionInterface
 {
 }

+ 2 - 2
lib/Predis/Connection/ComposableStreamConnection.php

@@ -26,11 +26,11 @@ class ComposableStreamConnection extends StreamConnection implements ComposableC
     protected $protocol;
 
     /**
-     * @param ConnectionParametersInterface $parameters Initialization parameters for the connection.
+     * @param ParametersInterface $parameters Initialization parameters for the connection.
      * @param ProtocolProcessorInterface $protocol Protocol processor.
      */
     public function __construct(
-        ConnectionParametersInterface $parameters,
+        ParametersInterface $parameters,
         ProtocolProcessorInterface $protocol = null
     ) {
         $this->parameters = $this->assertParameters($parameters);

+ 10 - 8
lib/Predis/Connection/ConnectionFactory.php → lib/Predis/Connection/Factory.php

@@ -20,7 +20,7 @@ use Predis\Command;
  *
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ConnectionFactory implements ConnectionFactoryInterface
+class Factory implements FactoryInterface
 {
     protected $schemes = array(
         'tcp'  => 'Predis\Connection\StreamConnection',
@@ -74,8 +74,8 @@ class ConnectionFactory implements ConnectionFactoryInterface
      */
     public function create($parameters)
     {
-        if (!$parameters instanceof ConnectionParametersInterface) {
-            $parameters = ConnectionParameters::create($parameters);
+        if (!$parameters instanceof ParametersInterface) {
+            $parameters = Parameters::create($parameters);
         }
 
         $scheme = $parameters->scheme;
@@ -106,7 +106,7 @@ class ConnectionFactory implements ConnectionFactoryInterface
     /**
      * {@inheritdoc}
      */
-    public function aggregate(AggregatedConnectionInterface $connection, array $parameters)
+    public function aggregate(AggregateConnectionInterface $connection, array $parameters)
     {
         foreach ($parameters as $node) {
             $connection->add($node instanceof SingleConnectionInterface ? $node : $this->create($node));
@@ -123,13 +123,15 @@ class ConnectionFactory implements ConnectionFactoryInterface
         $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))
+            );
         }
     }
 }

+ 3 - 3
lib/Predis/Connection/ConnectionFactoryInterface.php → lib/Predis/Connection/FactoryInterface.php

@@ -16,7 +16,7 @@ namespace Predis\Connection;
  *
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-interface ConnectionFactoryInterface
+interface FactoryInterface
 {
     /**
      * Defines or overrides the connection class identified by a scheme prefix.
@@ -44,8 +44,8 @@ interface ConnectionFactoryInterface
     /**
      * Aggregates single connections into an aggregate connection instance.
      *
-     * @param AggregatedConnectionInterface $aggregate Aggregate connection instance.
+     * @param AggregateConnectionInterface $aggregate Aggregate connection instance.
      * @param array $parameters List of parameters for each connection.
      */
-    public function aggregate(AggregatedConnectionInterface $aggregate, array $parameters);
+    public function aggregate(AggregateConnectionInterface $aggregate, array $parameters);
 }

+ 2 - 2
lib/Predis/Connection/ConnectionParameters.php → lib/Predis/Connection/Parameters.php

@@ -18,7 +18,7 @@ use InvalidArgumentException;
  *
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ConnectionParameters implements ConnectionParametersInterface
+class Parameters implements ParametersInterface
 {
     private $parameters;
 
@@ -70,7 +70,7 @@ class ConnectionParameters implements ConnectionParametersInterface
      * form of an URI string or a named array.
      *
      * @param array|string $parameters Set of connection parameters.
-     * @return ConnectionParameters
+     * @return Parameters
      */
     public static function create($parameters)
     {

+ 2 - 3
lib/Predis/Connection/ConnectionParametersInterface.php → lib/Predis/Connection/ParametersInterface.php

@@ -12,12 +12,11 @@
 namespace Predis\Connection;
 
 /**
- * Interface that must be implemented by classes that provide their own mechanism
- * to parse and handle connection parameters.
+ * Interface for classes providing their own logic for connection parameters.
  *
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-interface ConnectionParametersInterface
+interface ParametersInterface
 {
     /**
      * Checks if the specified parameters is set.

+ 10 - 10
lib/Predis/Connection/PhpiredisSocketConnection.php

@@ -48,7 +48,7 @@ class PhpiredisSocketConnection extends AbstractConnection
     /**
      * {@inheritdoc}
      */
-    public function __construct(ConnectionParametersInterface $parameters)
+    public function __construct(ParametersInterface $parameters)
     {
         $this->assertExtensions();
 
@@ -89,7 +89,7 @@ class PhpiredisSocketConnection extends AbstractConnection
     /**
      * {@inheritdoc}
      */
-    protected function assertParameters(ConnectionParametersInterface $parameters)
+    protected function assertParameters(ParametersInterface $parameters)
     {
         if (isset($parameters->persistent)) {
             throw new NotSupportedException(
@@ -186,9 +186,9 @@ class PhpiredisSocketConnection extends AbstractConnection
      * Sets options on the socket resource from the connection parameters.
      *
      * @param resource $socket Socket resource.
-     * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection.
+     * @param ParametersInterface $parameters Parameters used to initialize the connection.
      */
-    private function setSocketOptions($socket, ConnectionParametersInterface $parameters)
+    private function setSocketOptions($socket, ParametersInterface $parameters)
     {
         if ($parameters->scheme !== 'tcp') {
             return;
@@ -225,10 +225,10 @@ class PhpiredisSocketConnection extends AbstractConnection
     /**
      * Gets the address from the connection parameters.
      *
-     * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection.
+     * @param ParametersInterface $parameters Parameters used to initialize the connection.
      * @return string
      */
-    private static function getAddress(ConnectionParametersInterface $parameters)
+    private static function getAddress(ParametersInterface $parameters)
     {
         if ($parameters->scheme === 'unix') {
             return $parameters->path;
@@ -250,10 +250,10 @@ class PhpiredisSocketConnection extends AbstractConnection
     /**
      * Opens the actual connection to the server with a timeout.
      *
-     * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection.
+     * @param ParametersInterface $parameters Parameters used to initialize the connection.
      * @return string
      */
-    private function connectWithTimeout(ConnectionParametersInterface $parameters)
+    private function connectWithTimeout(ParametersInterface $parameters)
     {
         $host = self::getAddress($parameters);
         $socket = $this->getResource();
@@ -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);
             }
         }

+ 1 - 1
lib/Predis/Connection/PhpiredisStreamConnection.php

@@ -51,7 +51,7 @@ class PhpiredisStreamConnection extends StreamConnection
     /**
      * {@inheritdoc}
      */
-    public function __construct(ConnectionParametersInterface $parameters)
+    public function __construct(ParametersInterface $parameters)
     {
         $this->assertExtensions();
 

+ 1 - 1
lib/Predis/Connection/PredisCluster.php

@@ -19,7 +19,7 @@ use Predis\Cluster\Distributor;
 use Predis\Command\CommandInterface;
 
 /**
- * Abstraction for a cluster of aggregated connections to various Redis servers
+ * Abstraction for a cluster of aggregate connections to various Redis servers
  * implementing client-side sharding based on pluggable distribution strategies.
  *
  * @author Daniele Alessandri <suppakilla@gmail.com>

+ 3 - 3
lib/Predis/Connection/RedisCluster.php

@@ -55,12 +55,12 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou
     private $connections;
 
     /**
-     * @param ConnectionFactoryInterface $connections Connection factory object.
+     * @param FactoryInterface $connections Connection factory object.
      */
-    public function __construct(ConnectionFactoryInterface $connections = null)
+    public function __construct(FactoryInterface $connections = null)
     {
         $this->strategy = new Cluster\RedisStrategy();
-        $this->connections = $connections ?: new ConnectionFactory();
+        $this->connections = $connections ?: new Factory();
     }
 
     /**

+ 1 - 1
lib/Predis/Connection/ReplicationConnectionInterface.php

@@ -16,7 +16,7 @@ namespace Predis\Connection;
  *
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-interface ReplicationConnectionInterface extends AggregatedConnectionInterface
+interface ReplicationConnectionInterface extends AggregateConnectionInterface
 {
     /**
      * Switches the internal connection instance in use.

+ 2 - 2
lib/Predis/Connection/SingleConnectionInterface.php

@@ -37,7 +37,7 @@ interface SingleConnectionInterface extends ConnectionInterface
     /**
      * Returns the parameters used to initialize the connection.
      *
-     * @return ConnectionParametersInterface
+     * @return ParametersInterface
      */
     public function getParameters();
 
@@ -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.

+ 6 - 6
lib/Predis/Connection/StreamConnection.php

@@ -60,10 +60,10 @@ class StreamConnection extends AbstractConnection
     /**
      * Initializes a TCP stream resource.
      *
-     * @param ConnectionParametersInterface $parameters Initialization parameters for the connection.
+     * @param ParametersInterface $parameters Initialization parameters for the connection.
      * @return resource
      */
-    private function tcpStreamInitializer(ConnectionParametersInterface $parameters)
+    private function tcpStreamInitializer(ParametersInterface $parameters)
     {
         $uri = "tcp://{$parameters->host}:{$parameters->port}";
         $flags = STREAM_CLIENT_CONNECT;
@@ -102,10 +102,10 @@ class StreamConnection extends AbstractConnection
     /**
      * Initializes a UNIX stream resource.
      *
-     * @param ConnectionParametersInterface $parameters Initialization parameters for the connection.
+     * @param ParametersInterface $parameters Initialization parameters for the connection.
      * @return resource
      */
-    private function unixStreamInitializer(ConnectionParametersInterface $parameters)
+    private function unixStreamInitializer(ParametersInterface $parameters)
     {
         $uri = "unix://{$parameters->path}";
         $flags = STREAM_CLIENT_CONNECT;
@@ -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);
             }
         }

+ 7 - 7
lib/Predis/Connection/WebdisConnection.php

@@ -50,9 +50,9 @@ class WebdisConnection implements SingleConnectionInterface
     private $reader;
 
     /**
-     * @param ConnectionParametersInterface $parameters Initialization parameters for the connection.
+     * @param ParametersInterface $parameters Initialization parameters for the connection.
      */
-    public function __construct(ConnectionParametersInterface $parameters)
+    public function __construct(ParametersInterface $parameters)
     {
         $this->assertExtensions();
 
@@ -105,10 +105,10 @@ class WebdisConnection implements SingleConnectionInterface
     /**
      * Initializes cURL.
      *
-     * @param ConnectionParametersInterface $parameters Initialization parameters for the connection.
+     * @param ParametersInterface $parameters Initialization parameters for the connection.
      * @return resource
      */
-    private function createCurl(ConnectionParametersInterface $parameters)
+    private function createCurl(ParametersInterface $parameters)
     {
         $options = array(
             CURLOPT_FAILONERROR => true,
@@ -131,10 +131,10 @@ class WebdisConnection implements SingleConnectionInterface
     /**
      * Initializes the phpiredis protocol reader.
      *
-     * @param ConnectionParametersInterface $parameters Initialization parameters for the connection.
+     * @param ParametersInterface $parameters Initialization parameters for the connection.
      * @return resource
      */
-    private function createReader(ConnectionParametersInterface $parameters)
+    private function createReader(ParametersInterface $parameters)
     {
         $reader = phpiredis_reader_create();
 
@@ -296,7 +296,7 @@ class WebdisConnection implements SingleConnectionInterface
     /**
      * {@inheritdoc}
      */
-    public function pushInitCommand(CommandInterface $command)
+    public function addConnectCommand(CommandInterface $command)
     {
         $this->throwNotSupportedException(__FUNCTION__);
     }

+ 3 - 3
lib/Predis/Monitor/Consumer.php

@@ -14,7 +14,7 @@ namespace Predis\Monitor;
 use Iterator;
 use Predis\ClientInterface;
 use Predis\NotSupportedException;
-use Predis\Connection\AggregatedConnectionInterface;
+use Predis\Connection\AggregateConnectionInterface;
 
 /**
  * Redis MONITOR consumer.
@@ -54,9 +54,9 @@ class Consumer implements Iterator
      */
     private function assertClient(ClientInterface $client)
     {
-        if ($client->getConnection() instanceof AggregatedConnectionInterface) {
+        if ($client->getConnection() instanceof AggregateConnectionInterface) {
             throw new NotSupportedException(
-                'Cannot initialize a monitor consumer when using aggregated connections'
+                'Cannot initialize a monitor consumer when using aggregate connections'
             );
         }
 

+ 3 - 3
lib/Predis/PubSub/Consumer.php

@@ -15,7 +15,7 @@ use Predis\ClientException;
 use Predis\ClientInterface;
 use Predis\Command\Command;
 use Predis\NotSupportedException;
-use Predis\Connection\AggregatedConnectionInterface;
+use Predis\Connection\AggregateConnectionInterface;
 
 /**
  * PUB/SUB consumer abstraction.
@@ -59,9 +59,9 @@ class Consumer extends AbstractConsumer
      */
     private function checkCapabilities(ClientInterface $client)
     {
-        if ($client->getConnection() instanceof AggregatedConnectionInterface) {
+        if ($client->getConnection() instanceof AggregateConnectionInterface) {
             throw new NotSupportedException(
-                'Cannot initialize a PUB/SUB consumer when using aggregated connections'
+                'Cannot initialize a PUB/SUB consumer when using aggregate connections'
             );
         }
 

+ 4 - 4
lib/Predis/Transaction/MultiExec.php

@@ -21,7 +21,7 @@ use Predis\ExecutableContextInterface;
 use Predis\NotSupportedException;
 use Predis\Response;
 use Predis\Command\CommandInterface;
-use Predis\Connection\AggregatedConnectionInterface;
+use Predis\Connection\AggregateConnectionInterface;
 use Predis\Protocol\ProtocolException;
 
 /**
@@ -63,9 +63,9 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface
      */
     private function preconditions(ClientInterface $client)
     {
-        if ($client->getConnection() instanceof AggregatedConnectionInterface) {
+        if ($client->getConnection() instanceof AggregateConnectionInterface) {
             throw new NotSupportedException(
-                'Cannot initialize a MULTI/EXEC transaction when using aggregated connections'
+                'Cannot initialize a MULTI/EXEC transaction when using aggregate connections'
             );
         }
 
@@ -419,7 +419,7 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface
      */
     private function onProtocolError($message)
     {
-        // Since a MULTI/EXEC block cannot be initialized when using aggregated
+        // Since a MULTI/EXEC block cannot be initialized when using aggregate
         // connections we can safely assume that Predis\Client::getConnection()
         // will return a Predis\Connection\SingleConnectionInterface instance.
         CommunicationException::handle(new ProtocolException(

+ 2 - 2
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();
     }

+ 2 - 2
tests/PHPUnit/PredisTestCase.php

@@ -106,12 +106,12 @@ abstract class PredisTestCase extends PHPUnit_Framework_TestCase
      * Returns a new instance of connection parameters.
      *
      * @param array $additional Additional connection parameters.
-     * @return Connection\ConnectionParameters Default connection parameters.
+     * @return Connection\Parameters Default connection parameters.
      */
     protected function getParameters($additional = array())
     {
         $parameters = array_merge($this->getDefaultParametersArray(), $additional);
-        $parameters = new Connection\ConnectionParameters($parameters);
+        $parameters = new Connection\Parameters($parameters);
 
         return $parameters;
     }

+ 11 - 13
tests/Predis/ClientTest.php

@@ -12,9 +12,7 @@
 namespace Predis;
 
 use PredisTestCase;
-use Predis\Connection\ConnectionFactory;
-use Predis\Connection\MasterSlaveReplication;
-use Predis\Connection\PredisCluster;
+use Predis\Connection;
 use Predis\Profile;
 use Predis\Response;
 
@@ -152,7 +150,7 @@ class ClientTest extends PredisTestCase
      */
     public function testConstructorWithConnectionArgument()
     {
-        $factory = new ConnectionFactory();
+        $factory = new Connection\Factory();
         $connection = $factory->create('tcp://localhost:7000');
 
         $client = new Client($connection);
@@ -170,9 +168,9 @@ class ClientTest extends PredisTestCase
      */
     public function testConstructorWithClusterArgument()
     {
-        $cluster = new PredisCluster();
+        $cluster = new Connection\PredisCluster();
 
-        $factory = new ConnectionFactory();
+        $factory = new Connection\Factory();
         $factory->aggregate($cluster, array('tcp://localhost:7000', 'tcp://localhost:7001'));
 
         $client = new Client($cluster);
@@ -186,9 +184,9 @@ class ClientTest extends PredisTestCase
      */
     public function testConstructorWithReplicationArgument()
     {
-        $replication = new MasterSlaveReplication();
+        $replication = new Connection\MasterSlaveReplication();
 
-        $factory = new ConnectionFactory();
+        $factory = new Connection\Factory();
         $factory->aggregate($replication, array('tcp://host1?alias=master', 'tcp://host2?alias=slave'));
 
         $client = new Client($replication);
@@ -238,7 +236,7 @@ class ClientTest extends PredisTestCase
      */
     public function testConstructorWithNullAndArrayArgument()
     {
-        $factory = $this->getMock('Predis\Connection\ConnectionFactoryInterface');
+        $factory = $this->getMock('Predis\Connection\FactoryInterface');
 
         $arg2 = array('profile' => '2.0', 'prefix' => 'prefix:', 'connections' => $factory);
         $client = new Client(null, $arg2);
@@ -581,7 +579,7 @@ class ClientTest extends PredisTestCase
     /**
      * @group disconnected
      */
-    public function testGetConnectionFromAggregatedConnectionWithAlias()
+    public function testGetConnectionFromAggregateConnectionWithAlias()
     {
         $client = new Client(array('tcp://host1?alias=node01', 'tcp://host2?alias=node02'));
 
@@ -596,9 +594,9 @@ class ClientTest extends PredisTestCase
     /**
      * @group disconnected
      * @expectedException Predis\NotSupportedException
-     * @expectedExceptionMessage Retrieving connections by ID is supported only when using aggregated connections
+     * @expectedExceptionMessage Retrieving connections by ID is supported only when using aggregate connections
      */
-    public function testGetConnectionByIdWorksOnlyWithAggregatedConnections()
+    public function testGetConnectionByIdWorksOnlyWithAggregateConnections()
     {
         $client = new Client();
 
@@ -608,7 +606,7 @@ class ClientTest extends PredisTestCase
     /**
      * @group disconnected
      */
-    public function testCreateClientWithConnectionFromAggregatedConnection()
+    public function testCreateClientWithConnectionFromAggregateConnection()
     {
         $client = new Client(array('tcp://host1?alias=node01', 'tcp://host2?alias=node02'), array('prefix' => 'pfx:'));
 

+ 11 - 7
tests/Predis/CommunicationExceptionTest.php

@@ -12,7 +12,7 @@
 namespace Predis;
 
 use PredisTestCase;
-use Predis\Connection\SingleConnectionInterface;
+use Predis\Connection;
 
 /**
  *
@@ -79,7 +79,7 @@ class CommunicationExceptionTest extends PredisTestCase
      * Returns a mocked connection instance.
      *
      * @param mixed $parameters Connection parameters.
-     * @return SingleConnectionInterface
+     * @return Connection\SingleConnectionInterface
      */
     protected function getMockedConnectionBase($parameters = null)
     {
@@ -87,8 +87,8 @@ class CommunicationExceptionTest extends PredisTestCase
 
         if ($parameters === null) {
             $builder->disableOriginalConstructor();
-        } else if (!$parameters instanceof ConnectionParametersInterface) {
-            $parameters = new ConnectionParameters($parameters);
+        } else if (!$parameters instanceof Connection\ParametersInterface) {
+            $parameters = new Connection\Parameters($parameters);
         }
 
         return $builder->getMockForAbstractClass(array($parameters));
@@ -97,14 +97,18 @@ class CommunicationExceptionTest extends PredisTestCase
     /**
      * Returns a connection exception instance.
      *
-     * @param SingleConnectionInterface $message Connection instance.
+     * @param Connection\SingleConnectionInterface $message Connection instance.
      * @param string $message Exception message.
      * @param int $code Exception code.
      * @param \Exception $inner Inner exception.
      * @return \Exception
      */
-    protected function getException(SingleConnectionInterface $connection, $message, $code = 0, \Exception $inner = null)
-    {
+    protected function getException(
+        Connection\SingleConnectionInterface $connection,
+        $message,
+        $code = 0,
+        \Exception $inner = null
+    ) {
         $arguments = array($connection, $message, $code, $inner);
         $mock = $this->getMockForAbstractClass('Predis\CommunicationException', $arguments);
 

+ 4 - 5
tests/Predis/Configuration/ConnectionFactoryOptionTest.php

@@ -14,7 +14,6 @@ namespace Predis\Configuration;
 use InvalidArgumentException;
 use stdClass;
 use PredisTestCase;
-use Predis\Connection\ConnectionFactory;
 
 /**
  *
@@ -29,7 +28,7 @@ class ConnectionFactoryOptionTest extends PredisTestCase
         $option = new ConnectionFactoryOption();
         $options = $this->getMock('Predis\Configuration\OptionsInterface');
 
-        $this->assertInstanceOf('Predis\Connection\ConnectionFactory', $option->getDefault($options));
+        $this->assertInstanceOf('Predis\Connection\Factory', $option->getDefault($options));
     }
 
     /**
@@ -43,7 +42,7 @@ class ConnectionFactoryOptionTest extends PredisTestCase
         $class = get_class($this->getMock('Predis\Connection\SingleConnectionInterface'));
         $value = array('tcp' => $class, 'redis' => $class);
 
-        $default = $this->getMock('Predis\Connection\ConnectionFactoryInterface');
+        $default = $this->getMock('Predis\Connection\FactoryInterface');
         $default->expects($this->exactly(2))
                 ->method('define')
                 ->with($this->matchesRegularExpression('/^tcp|redis$/'), $class);
@@ -54,7 +53,7 @@ class ConnectionFactoryOptionTest extends PredisTestCase
                ->with($options)
                ->will($this->returnValue($default));
 
-        $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $factory = $option->filter($options, $value));
+        $this->assertInstanceOf('Predis\Connection\FactoryInterface', $factory = $option->filter($options, $value));
         $this->assertSame($default, $factory);
     }
 
@@ -65,7 +64,7 @@ class ConnectionFactoryOptionTest extends PredisTestCase
     {
         $option = new ConnectionFactoryOption();
         $options = $this->getMock('Predis\Configuration\OptionsInterface');
-        $value = $this->getMock('Predis\Connection\ConnectionFactoryInterface');
+        $value = $this->getMock('Predis\Connection\FactoryInterface');
 
         $option = $this->getMock('Predis\Configuration\ConnectionFactoryOption', array('getDefault'));
         $option->expects($this->never())->method('getDefault');

+ 3 - 3
tests/Predis/Configuration/OptionsTest.php

@@ -27,7 +27,7 @@ class OptionsTest extends PredisTestCase
     {
         $options = new Options();
 
-        $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $options->connections);
+        $this->assertInstanceOf('Predis\Connection\FactoryInterface', $options->connections);
         $this->assertInstanceOf('Predis\Profile\ProfileInterface', $options->profile);
         $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $options->cluster);
         $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $options->replication);
@@ -44,7 +44,7 @@ class OptionsTest extends PredisTestCase
             'exceptions'  => false,
             'profile'     => '2.0',
             'prefix'      => 'prefix:',
-            'connections' => $this->getMock('Predis\Connection\ConnectionFactoryInterface'),
+            'connections' => $this->getMock('Predis\Connection\FactoryInterface'),
             'cluster'     => $this->getMock('Predis\Connection\ClusterConnectionInterface'),
             'replication' => $this->getMock('Predis\Connection\ReplicationConnectionInterface'),
         ));
@@ -52,7 +52,7 @@ class OptionsTest extends PredisTestCase
         $this->assertInternalType('bool', $options->exceptions);
         $this->assertInstanceOf('Predis\Profile\ProfileInterface', $options->profile);
         $this->assertInstanceOf('Predis\Command\Processor\CommandProcessorInterface', $options->prefix);
-        $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $options->connections);
+        $this->assertInstanceOf('Predis\Connection\FactoryInterface', $options->connections);
         $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $options->cluster);
         $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $options->replication);
     }

+ 7 - 2
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;

+ 31 - 31
tests/Predis/Connection/ConnectionFactoryTest.php → tests/Predis/Connection/FactoryTest.php

@@ -16,16 +16,16 @@ use PredisTestCase;
 /**
  *
  */
-class ConnectionFactoryTest extends PredisTestCase
+class FactoryTest extends PredisTestCase
 {
     /**
      * @group disconnected
      */
     public function testImplementsCorrectInterface()
     {
-        $factory = new ConnectionFactory();
+        $factory = new Factory();
 
-        $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $factory);
+        $this->assertInstanceOf('Predis\Connection\FactoryInterface', $factory);
     }
 
     /**
@@ -33,9 +33,9 @@ class ConnectionFactoryTest extends PredisTestCase
      */
     public function testCreateConnection()
     {
-        $factory = new ConnectionFactory();
+        $factory = new Factory();
 
-        $tcp = new ConnectionParameters(array(
+        $tcp = new Parameters(array(
             'scheme' => 'tcp',
             'host' => 'locahost',
         ));
@@ -48,7 +48,7 @@ class ConnectionFactoryTest extends PredisTestCase
         $this->assertEquals($tcp->database, $parameters->database);
 
 
-        $unix = new ConnectionParameters(array(
+        $unix = new Parameters(array(
             'scheme' => 'unix',
             'path' => '/tmp/redis.sock',
         ));
@@ -65,7 +65,7 @@ class ConnectionFactoryTest extends PredisTestCase
      */
     public function testCreateConnectionWithNullParameters()
     {
-        $factory = new ConnectionFactory();
+        $factory = new Factory();
         $connection = $factory->create(null);
         $parameters = $connection->getParameters();
 
@@ -81,7 +81,7 @@ class ConnectionFactoryTest extends PredisTestCase
      */
     public function testCreateConnectionWithArrayParameters()
     {
-        $factory = new ConnectionFactory();
+        $factory = new Factory();
         $connection = $factory->create(array('scheme' => 'tcp', 'custom' => 'foobar'));
         $parameters = $connection->getParameters();
 
@@ -97,7 +97,7 @@ class ConnectionFactoryTest extends PredisTestCase
      */
     public function testCreateConnectionWithStringURI()
     {
-        $factory = new ConnectionFactory();
+        $factory = new Factory();
         $connection = $factory->create('tcp://127.0.0.1?custom=foobar');
         $parameters = $connection->getParameters();
 
@@ -116,8 +116,8 @@ class ConnectionFactoryTest extends PredisTestCase
         $profile = $this->getMock('Predis\Profile\ProfileInterface');
         $profile->expects($this->never())->method('create');
 
-        $factory = new ConnectionFactory($profile);
-        $parameters = new ConnectionParameters();
+        $factory = new Factory($profile);
+        $parameters = new Parameters();
         $connection = $factory->create($parameters);
 
         $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection);
@@ -129,7 +129,7 @@ class ConnectionFactoryTest extends PredisTestCase
      */
     public function testCreateConnectionWithInitializationCommands()
     {
-        $parameters = new ConnectionParameters(array(
+        $parameters = new Parameters(array(
             'database' => '0',
             'password' => 'foobar'
         ));
@@ -139,13 +139,13 @@ class ConnectionFactoryTest 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 ConnectionFactory();
+        $factory = new Factory();
 
         $reflection = new \ReflectionObject($factory);
         $prepareConnection = $reflection->getMethod('prepareConnection');
@@ -161,8 +161,8 @@ class ConnectionFactoryTest extends PredisTestCase
         $scheme = 'unknown';
         $this->setExpectedException('InvalidArgumentException', "Unknown connection scheme: $scheme");
 
-        $factory = new ConnectionFactory();
-        $factory->create(new ConnectionParameters(array('scheme' => $scheme)));
+        $factory = new Factory();
+        $factory->create(new Parameters(array('scheme' => $scheme)));
     }
 
     /**
@@ -172,8 +172,8 @@ class ConnectionFactoryTest extends PredisTestCase
     {
         list(, $connectionClass) = $this->getMockConnectionClass();
 
-        $parameters = new ConnectionParameters(array('scheme' => 'foobar'));
-        $factory = new ConnectionFactory();
+        $parameters = new Parameters(array('scheme' => 'foobar'));
+        $factory = new Factory();
 
         $factory->define($parameters->scheme, $connectionClass);
         $connection = $factory->create($parameters);
@@ -188,7 +188,7 @@ class ConnectionFactoryTest extends PredisTestCase
     {
         list(, $connectionClass) = $this->getMockConnectionClass();
 
-        $parameters = new ConnectionParameters(array('scheme' => 'foobar'));
+        $parameters = new Parameters(array('scheme' => 'foobar'));
 
         $initializer = function ($parameters) use ($connectionClass) {
             return new $connectionClass($parameters);
@@ -200,7 +200,7 @@ class ConnectionFactoryTest extends PredisTestCase
                         ->with($parameters)
                         ->will($this->returnCallback($initializer));
 
-        $factory = new ConnectionFactory();
+        $factory = new Factory();
         $factory->define($parameters->scheme, $initializerMock);
         $connection1 = $factory->create($parameters);
         $connection2 = $factory->create($parameters);
@@ -217,7 +217,7 @@ class ConnectionFactoryTest extends PredisTestCase
     {
         $this->setExpectedException('InvalidArgumentException');
 
-        $factory = new ConnectionFactory();
+        $factory = new Factory();
         $factory->define('foobar', new \stdClass());
     }
 
@@ -228,7 +228,7 @@ class ConnectionFactoryTest extends PredisTestCase
     {
         $this->setExpectedException('InvalidArgumentException', 'Unknown connection scheme: tcp');
 
-        $factory = new ConnectionFactory();
+        $factory = new Factory();
         $factory->undefine('tcp');
         $factory->create('tcp://127.0.0.1');
     }
@@ -238,7 +238,7 @@ class ConnectionFactoryTest extends PredisTestCase
      */
     public function testUndefineUndefinedConnection()
     {
-        $factory = new ConnectionFactory();
+        $factory = new Factory();
         $factory->undefine('unknown');
         $connection = $factory->create('tcp://127.0.0.1');
 
@@ -252,7 +252,7 @@ class ConnectionFactoryTest extends PredisTestCase
     {
         list(, $connectionClass) = $this->getMockConnectionClass();
 
-        $factory = new ConnectionFactory();
+        $factory = new Factory();
 
         $factory->define('redis', $connectionClass);
         $this->assertInstanceOf($connectionClass, $factory->create('redis://127.0.0.1'));
@@ -265,7 +265,7 @@ class ConnectionFactoryTest extends PredisTestCase
     /**
      * @group disconnected
      */
-    public function testAggregatedConnectionSkipCreationOnConnectionInstance()
+    public function testAggregateConnectionSkipCreationOnConnectionInstance()
     {
         list(, $connectionClass) = $this->getMockConnectionClass();
 
@@ -274,7 +274,7 @@ class ConnectionFactoryTest extends PredisTestCase
                 ->method('add')
                 ->with($this->isInstanceOf('Predis\Connection\SingleConnectionInterface'));
 
-        $factory = $this->getMock('Predis\Connection\ConnectionFactory', array('create'));
+        $factory = $this->getMock('Predis\Connection\Factory', array('create'));
         $factory->expects($this->never())
                 ->method('create');
 
@@ -284,7 +284,7 @@ class ConnectionFactoryTest extends PredisTestCase
     /**
      * @group disconnected
      */
-    public function testAggregatedConnectionWithMixedParameters()
+    public function testAggregateConnectionWithMixedParameters()
     {
         list(, $connectionClass) = $this->getMockConnectionClass();
 
@@ -293,7 +293,7 @@ class ConnectionFactoryTest extends PredisTestCase
                 ->method('add')
                 ->with($this->isInstanceOf('Predis\Connection\SingleConnectionInterface'));
 
-        $factory = $this->getMock('Predis\Connection\ConnectionFactory', array('create'));
+        $factory = $this->getMock('Predis\Connection\Factory', array('create'));
         $factory->expects($this->exactly(3))
                 ->method('create')
                 ->will($this->returnCallback(function ($_) use ($connectionClass) {
@@ -306,12 +306,12 @@ class ConnectionFactoryTest extends PredisTestCase
     /**
      * @group disconnected
      */
-    public function testAggregatedConnectionWithEmptyListOfParameters()
+    public function testAggregateConnectionWithEmptyListOfParameters()
     {
         $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface');
         $cluster->expects($this->never())->method('add');
 
-        $factory = $this->getMock('Predis\Connection\ConnectionFactory', array('create'));
+        $factory = $this->getMock('Predis\Connection\Factory', array('create'));
         $factory->expects($this->never())->method('create');
 
         $factory->aggregate($cluster, array());

+ 1 - 1
tests/Predis/Connection/MasterSlaveReplicationTest.php

@@ -576,7 +576,7 @@ class MasterSlaveReplicationTest extends PredisTestCase
         $connection = $this->getMock('Predis\Connection\SingleConnectionInterface');
 
         if ($parameters) {
-            $parameters = ConnectionParameters::create($parameters);
+            $parameters = Parameters::create($parameters);
             $hash = "{$parameters->host}:{$parameters->port}";
 
             $connection->expects($this->any())

+ 17 - 17
tests/Predis/Connection/ConnectionParametersTest.php → tests/Predis/Connection/ParametersTest.php

@@ -14,10 +14,10 @@ namespace Predis\Connection;
 use PredisTestCase;
 
 /**
- * @todo ConnectionParameters::define();
- * @todo ConnectionParameters::undefine();
+ * @todo Parameters::define();
+ * @todo Parameters::undefine();
  */
-class ConnectionParametersTest extends PredisTestCase
+class ParametersTest extends PredisTestCase
 {
     /**
      * @group disconnected
@@ -25,7 +25,7 @@ class ConnectionParametersTest extends PredisTestCase
     public function testDefaultValues()
     {
         $defaults = $this->getDefaultParametersArray();
-        $parameters = new ConnectionParameters();
+        $parameters = new Parameters();
 
         $this->assertEquals($defaults['scheme'], $parameters->scheme);
         $this->assertEquals($defaults['host'], $parameters->host);
@@ -38,13 +38,13 @@ class ConnectionParametersTest extends PredisTestCase
      */
     public function testIsSet()
     {
-        $parameters = new ConnectionParameters();
+        $parameters = new Parameters();
 
         $this->assertTrue(isset($parameters->scheme));
         $this->assertFalse(isset($parameters->unknown));
     }
 
-    public function sharedTestsWithArrayParameters(ConnectionParameters $parameters)
+    public function sharedTestsWithArrayParameters(Parameters $parameters)
     {
         $this->assertTrue(isset($parameters->scheme));
         $this->assertSame('tcp', $parameters->scheme);
@@ -64,7 +64,7 @@ class ConnectionParametersTest extends PredisTestCase
      */
     public function testConstructWithArrayParameters()
     {
-        $parameters = new ConnectionParameters(array(
+        $parameters = new Parameters(array(
             'port' => 7000,
             'custom' => 'foobar'
         ));
@@ -77,7 +77,7 @@ class ConnectionParametersTest extends PredisTestCase
      */
     public function testCreateWithArrayParameters()
     {
-        $parameters = new ConnectionParameters(array(
+        $parameters = new Parameters(array(
             'port' => 7000,
             'custom' => 'foobar'
         ));
@@ -99,7 +99,7 @@ class ConnectionParametersTest extends PredisTestCase
         );
 
         $uriString = $this->getParametersString($overrides);
-        $parameters = ConnectionParameters::create($uriString);
+        $parameters = Parameters::create($uriString);
 
         $this->sharedTestsWithArrayParameters($parameters);
         $this->assertEquals($overrides['database'], $parameters->database);
@@ -111,7 +111,7 @@ class ConnectionParametersTest extends PredisTestCase
     public function testToArray()
     {
         $additional = array('port' => 7000, 'custom' => 'foobar');
-        $parameters = new ConnectionParameters($additional);
+        $parameters = new Parameters($additional);
 
         $this->assertEquals($this->getParametersArray($additional), $parameters->toArray());
     }
@@ -121,7 +121,7 @@ class ConnectionParametersTest extends PredisTestCase
      */
     public function testSerialization()
     {
-        $parameters = new ConnectionParameters(array('port' => 7000, 'custom' => 'foobar'));
+        $parameters = new Parameters(array('port' => 7000, 'custom' => 'foobar'));
         $unserialized = unserialize(serialize($parameters));
 
         $this->assertEquals($parameters->scheme, $unserialized->scheme);
@@ -149,7 +149,7 @@ class ConnectionParametersTest extends PredisTestCase
             'persistent' => '1',
         );
 
-        $this->assertSame($expected, ConnectionParameters::parse($uri));
+        $this->assertSame($expected, Parameters::parse($uri));
     }
 
     /**
@@ -167,7 +167,7 @@ class ConnectionParametersTest extends PredisTestCase
             'persistent' => '1',
         );
 
-        $this->assertSame($expected, ConnectionParameters::parse($uri));
+        $this->assertSame($expected, Parameters::parse($uri));
     }
 
     /**
@@ -185,7 +185,7 @@ class ConnectionParametersTest extends PredisTestCase
             'bar' => '',
         );
 
-        $this->assertSame($expected, ConnectionParameters::parse($uri));
+        $this->assertSame($expected, Parameters::parse($uri));
     }
 
     /**
@@ -202,7 +202,7 @@ class ConnectionParametersTest extends PredisTestCase
             'persistent' => '1',
         );
 
-        $this->assertSame($expected, ConnectionParameters::parse($uri));
+        $this->assertSame($expected, Parameters::parse($uri));
     }
 
     /**
@@ -219,7 +219,7 @@ class ConnectionParametersTest extends PredisTestCase
             'metavars' => array('foo', 'hoge'),
         );
 
-        $this->assertSame($expected, ConnectionParameters::parse($uri));
+        $this->assertSame($expected, Parameters::parse($uri));
     }
 
     /**
@@ -229,7 +229,7 @@ class ConnectionParametersTest extends PredisTestCase
      */
     public function testParsingURIThrowOnInvalidURI()
     {
-        ConnectionParameters::parse('tcp://invalid:uri');
+        Parameters::parse('tcp://invalid:uri');
     }
 
     // ******************************************************************** //

+ 7 - 2
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;

+ 7 - 2
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;

+ 1 - 1
tests/Predis/Connection/PredisClusterTest.php

@@ -388,7 +388,7 @@ class PredisClusterTest extends PredisTestCase
         $connection = $this->getMock('Predis\Connection\SingleConnectionInterface');
 
         if ($parameters) {
-            $parameters = ConnectionParameters::create($parameters);
+            $parameters = Parameters::create($parameters);
             $hash = "{$parameters->host}:{$parameters->port}";
 
             $connection->expects($this->any())

+ 5 - 5
tests/Predis/Connection/RedisClusterTest.php

@@ -472,7 +472,7 @@ class RedisClusterTest extends PredisTestCase
                     ->with($command)
                     ->will($this->returnValue('foobar'));
 
-        $factory = $this->getMock('Predis\Connection\ConnectionFactory');
+        $factory = $this->getMock('Predis\Connection\Factory');
         $factory->expects($this->never())->method('create');
 
         $cluster = new RedisCluster($factory);
@@ -512,7 +512,7 @@ class RedisClusterTest extends PredisTestCase
                     ->with($command)
                     ->will($this->returnValue('foobar'));
 
-        $factory = $this->getMock('Predis\Connection\ConnectionFactory');
+        $factory = $this->getMock('Predis\Connection\Factory');
         $factory->expects($this->once())
                 ->method('create')
                 ->with(array('host' => '127.0.0.1', 'port' => '6381'))
@@ -549,7 +549,7 @@ class RedisClusterTest extends PredisTestCase
                     ->will($this->onConsecutiveCalls('foobar', 'foobar'));
 
 
-        $factory = $this->getMock('Predis\Connection\ConnectionFactory');
+        $factory = $this->getMock('Predis\Connection\Factory');
         $factory->expects($this->never())->method('create');
 
         $cluster = new RedisCluster($factory);
@@ -586,7 +586,7 @@ class RedisClusterTest extends PredisTestCase
                     ->with($command)
                     ->will($this->onConsecutiveCalls('foobar', 'foobar'));
 
-        $factory = $this->getMock('Predis\Connection\ConnectionFactory');
+        $factory = $this->getMock('Predis\Connection\Factory');
         $factory->expects($this->once())
                 ->method('create')
                 ->with(array('host' => '127.0.0.1', 'port' => '6381'))
@@ -652,7 +652,7 @@ class RedisClusterTest extends PredisTestCase
         $connection = $this->getMock('Predis\Connection\SingleConnectionInterface');
 
         if ($parameters) {
-            $parameters = ConnectionParameters::create($parameters);
+            $parameters = Parameters::create($parameters);
             $hash = "{$parameters->host}:{$parameters->port}";
 
             $connection->expects($this->any())

+ 7 - 2
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;

+ 4 - 3
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'));
     }
 
     /**

+ 1 - 1
tests/Predis/Monitor/ConsumerTest.php

@@ -41,7 +41,7 @@ class ConsumerTest extends PredisTestCase
     /**
      * @group disconnected
      * @expectedException Predis\NotSupportedException
-     * @expectedExceptionMessage Cannot initialize a monitor consumer when using aggregated connections
+     * @expectedExceptionMessage Cannot initialize a monitor consumer when using aggregate connections
      */
     public function testMonitorConsumerDoesNotWorkOnClusters()
     {

+ 1 - 1
tests/Predis/Pipeline/AtomicTest.php

@@ -152,7 +152,7 @@ class AtomicTest extends PredisTestCase
      * @expectedException Predis\ClientException
      * @expectedExceptionMessage Predis\Pipeline\Atomic can be used only with connections to single nodes
      */
-    public function testExecutorWithAggregatedConnection()
+    public function testExecutorWithAggregateConnection()
     {
         $connection = $this->getMock('Predis\Connection\ClusterConnectionInterface');
         $pipeline = new Atomic(new Client($connection));

+ 1 - 1
tests/Predis/PubSub/ConsumerTest.php

@@ -40,7 +40,7 @@ class ConsumerTest extends PredisTestCase
     /**
      * @group disconnected
      * @expectedException Predis\NotSupportedException
-     * @expectedExceptionMessage Cannot initialize a PUB/SUB consumer when using aggregated connections
+     * @expectedExceptionMessage Cannot initialize a PUB/SUB consumer when using aggregate connections
      */
     public function testPubSubConsumerDoesNotWorkOnClusters()
     {

+ 0 - 1
tests/Predis/Response/Iterator/MultiBulkTest.php

@@ -14,7 +14,6 @@ namespace Predis\Response\Iterator;
 use PredisTestCase;
 use Predis\Client;
 use Predis\Connection\ComposableStreamConnection;
-use Predis\Connection\ConnectionParameters;
 use Predis\Protocol\Text\ProtocolProcessor as TextProtocolProcessor;
 
 /**

+ 0 - 1
tests/Predis/Response/Iterator/MultiBulkTupleTest.php

@@ -14,7 +14,6 @@ namespace Predis\Response\Iterator;
 use PredisTestCase;
 use Predis\Client;
 use Predis\Connection\ComposableStreamConnection;
-use Predis\Connection\ConnectionParameters;
 use Predis\Protocol\Text\ProtocolProcessor as TextProtocolProcessor;
 
 /**