diff --git a/CHANGELOG.md b/CHANGELOG.md index adc3b8cc..648eb766 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,9 @@ v1.0.0 (201x-xx-xx) its constructor accepts only named arrays, but instances can still be created using both URIs or arrays using the static method `Parameters::create()`. +- The `Predis\Connection` namespace has been completely reorganized by renaming + a few classes and interfaces and adding some sub-namespaces. + - Most classes and interfaces in the `Predis\Protocol` namespace have been moved or renamed while rationalizing the whole API for external protocol processors. diff --git a/README.md b/README.md index 392d4de4..f035e371 100644 --- a/README.md +++ b/README.md @@ -195,10 +195,10 @@ $client = new Predis\Client('tcp://127.0.0.1', [ Developers can create their own connection classes to add support for new network backends, extend existing ones or provide completely different implementations. Connection classes must implement -`Predis\Connection\SingleConnectionInterface` or extend `Predis\Connection\AbstractConnection`: +`Predis\Connection\NodeConnectionInterface` or extend `Predis\Connection\AbstractConnection`: ```php -class MyConnectionClass implements Predis\Connection\SingleConnectionInterface +class MyConnectionClass implements Predis\Connection\NodeConnectionInterface { // Implementation goes here... } diff --git a/examples/custom_cluster_distributor.php b/examples/custom_cluster_distributor.php index 3c5db0eb..0acacfdf 100644 --- a/examples/custom_cluster_distributor.php +++ b/examples/custom_cluster_distributor.php @@ -15,7 +15,7 @@ require __DIR__.'/shared.php'; // their own distributors used by the client to distribute keys among a cluster // of servers. -use Predis\Connection\PredisCluster; +use Predis\Connection\Aggregate\PredisCluster; use Predis\Cluster\Distributor\DistributorInterface; use Predis\Cluster\Hash\HashGeneratorInterface; diff --git a/examples/replication_complex.php b/examples/replication_complex.php index 8288c79b..2d63496c 100644 --- a/examples/replication_complex.php +++ b/examples/replication_complex.php @@ -19,7 +19,7 @@ require __DIR__.'/shared.php'; // operation for replication so that it will be executed on slaves. use Predis\Command\ScriptCommand; -use Predis\Connection\MasterSlaveReplication; +use Predis\Connection\Aggregate\MasterSlaveReplication; use Predis\Replication\ReplicationStrategy; // ------------------------------------------------------------------------- // diff --git a/lib/Predis/Client.php b/lib/Predis/Client.php index 0a708d6b..e1af1390 100644 --- a/lib/Predis/Client.php +++ b/lib/Predis/Client.php @@ -241,8 +241,8 @@ class Client implements ClientInterface * Retrieves the specified connection from the aggregate connection when the * client is in cluster or replication mode. * - * @param string $connectionID Index or alias of the single connection. - * @return Connection\SingleConnectionInterface + * @param string $connectionID Index or alias of the single connection. + * @return Connection\NodeConnectionInterface */ public function getConnectionById($connectionID) { diff --git a/lib/Predis/Command/ServerInfo.php b/lib/Predis/Command/ServerInfo.php index 3fcf2c84..1a636f10 100644 --- a/lib/Predis/Command/ServerInfo.php +++ b/lib/Predis/Command/ServerInfo.php @@ -48,7 +48,7 @@ class ServerInfo extends Command /** * Parses a single row of the response and returns the key-value pair. * - * @param string $row Single row of the response. + * @param string $row Single row of the response. * @return array */ protected function parseRow($row) @@ -62,6 +62,7 @@ class ServerInfo extends Command } else { $v = $this->parseDatabaseStats($v); } + return array($k, $v); } diff --git a/lib/Predis/CommunicationException.php b/lib/Predis/CommunicationException.php index ff7113cf..c3789a51 100644 --- a/lib/Predis/CommunicationException.php +++ b/lib/Predis/CommunicationException.php @@ -12,7 +12,7 @@ namespace Predis; use Exception; -use Predis\Connection\SingleConnectionInterface; +use Predis\Connection\NodeConnectionInterface; /** * Base exception class for network-related errors. @@ -24,13 +24,13 @@ abstract class CommunicationException extends PredisException private $connection; /** - * @param SingleConnectionInterface $connection Connection that generated the exception. - * @param string $message Error message. - * @param int $code Error code. - * @param Exception $innerException Inner exception for wrapping the original error. + * @param NodeConnectionInterface $connection Connection that generated the exception. + * @param string $message Error message. + * @param int $code Error code. + * @param Exception $innerException Inner exception for wrapping the original error. */ public function __construct( - SingleConnectionInterface $connection, + NodeConnectionInterface $connection, $message = null, $code = null, Exception $innerException = null @@ -42,7 +42,7 @@ abstract class CommunicationException extends PredisException /** * Gets the connection that generated the exception. * - * @return SingleConnectionInterface + * @return NodeConnectionInterface */ public function getConnection() { diff --git a/lib/Predis/Configuration/ClusterOption.php b/lib/Predis/Configuration/ClusterOption.php index 048cd4ba..ebc1e0c1 100644 --- a/lib/Predis/Configuration/ClusterOption.php +++ b/lib/Predis/Configuration/ClusterOption.php @@ -12,9 +12,9 @@ namespace Predis\Configuration; use InvalidArgumentException; -use Predis\Connection\ClusterConnectionInterface; -use Predis\Connection\PredisCluster; -use Predis\Connection\RedisCluster; +use Predis\Connection\Aggregate\ClusterInterface; +use Predis\Connection\Aggregate\PredisCluster; +use Predis\Connection\Aggregate\RedisCluster; /** * Configures an aggregate connection used for clustering @@ -28,9 +28,9 @@ class ClusterOption implements OptionInterface /** * Creates a new cluster connection from on a known descriptive name. * - * @param OptionsInterface $options Instance of the client options. - * @param string $id Descriptive identifier of the cluster type (`predis`, `redis-cluster`) - * @return ClusterConnectionInterface + * @param OptionsInterface $options Instance of the client options. + * @param string $id Descriptive identifier of the cluster type (`predis`, `redis-cluster`) + * @return ClusterInterface */ protected function createByDescription(OptionsInterface $options, $id) { @@ -55,9 +55,9 @@ class ClusterOption implements OptionInterface $value = $this->createByDescription($options, $value); } - if (!$value instanceof ClusterConnectionInterface) { + if (!$value instanceof ClusterInterface) { throw new InvalidArgumentException( - "An instance of type 'Predis\Connection\ClusterConnectionInterface' was expected." + "An instance of type 'Predis\Connection\Aggregate\ClusterInterface' was expected." ); } diff --git a/lib/Predis/Configuration/ReplicationOption.php b/lib/Predis/Configuration/ReplicationOption.php index 23282936..57af933b 100644 --- a/lib/Predis/Configuration/ReplicationOption.php +++ b/lib/Predis/Configuration/ReplicationOption.php @@ -12,11 +12,11 @@ namespace Predis\Configuration; use InvalidArgumentException; -use Predis\Connection\MasterSlaveReplication; -use Predis\Connection\ReplicationConnectionInterface; +use Predis\Connection\Aggregate\MasterSlaveReplication; +use Predis\Connection\Aggregate\ReplicationInterface; /** - * Configures an aggregate connection used for master/slave replication between + * Configures an aggregate connection used for master/slave replication among * multiple Redis nodes. * * @author Daniele Alessandri @@ -32,7 +32,7 @@ class ReplicationOption implements OptionInterface */ public function filter(OptionsInterface $options, $value) { - if ($value instanceof ReplicationConnectionInterface) { + if ($value instanceof ReplicationInterface) { return $value; } @@ -48,7 +48,7 @@ class ReplicationOption implements OptionInterface } throw new InvalidArgumentException( - "An instance of type 'Predis\Connection\ReplicationConnectionInterface' was expected." + "An instance of type 'Predis\Connection\Aggregate\ReplicationInterface' was expected." ); } diff --git a/lib/Predis/Connection/AbstractConnection.php b/lib/Predis/Connection/AbstractConnection.php index 1322b2e7..e22cf4f1 100644 --- a/lib/Predis/Connection/AbstractConnection.php +++ b/lib/Predis/Connection/AbstractConnection.php @@ -22,7 +22,7 @@ use Predis\Protocol\ProtocolException; * * @author Daniele Alessandri */ -abstract class AbstractConnection implements SingleConnectionInterface +abstract class AbstractConnection implements NodeConnectionInterface { private $resource; private $cachedId; diff --git a/lib/Predis/Connection/ClusterConnectionInterface.php b/lib/Predis/Connection/Aggregate/ClusterInterface.php similarity index 73% rename from lib/Predis/Connection/ClusterConnectionInterface.php rename to lib/Predis/Connection/Aggregate/ClusterInterface.php index 4140ad33..af0f5aab 100644 --- a/lib/Predis/Connection/ClusterConnectionInterface.php +++ b/lib/Predis/Connection/Aggregate/ClusterInterface.php @@ -9,7 +9,9 @@ * file that was distributed with this source code. */ -namespace Predis\Connection; +namespace Predis\Connection\Aggregate; + +use Predis\Connection\AggregateConnectionInterface; /** * Defines a cluster of Redis servers formed by aggregating multiple connection @@ -17,6 +19,6 @@ namespace Predis\Connection; * * @author Daniele Alessandri */ -interface ClusterConnectionInterface extends AggregateConnectionInterface +interface ClusterInterface extends AggregateConnectionInterface { } diff --git a/lib/Predis/Connection/MasterSlaveReplication.php b/lib/Predis/Connection/Aggregate/MasterSlaveReplication.php similarity index 93% rename from lib/Predis/Connection/MasterSlaveReplication.php rename to lib/Predis/Connection/Aggregate/MasterSlaveReplication.php index b0fa1088..fa7bcda5 100644 --- a/lib/Predis/Connection/MasterSlaveReplication.php +++ b/lib/Predis/Connection/Aggregate/MasterSlaveReplication.php @@ -9,11 +9,12 @@ * file that was distributed with this source code. */ -namespace Predis\Connection; +namespace Predis\Connection\Aggregate; use InvalidArgumentException; use RuntimeException; use Predis\Command\CommandInterface; +use Predis\Connection\NodeConnectionInterface; use Predis\Replication\ReplicationStrategy; /** @@ -22,7 +23,7 @@ use Predis\Replication\ReplicationStrategy; * * @author Daniele Alessandri */ -class MasterSlaveReplication implements ReplicationConnectionInterface +class MasterSlaveReplication implements ReplicationInterface { protected $strategy; protected $master; @@ -59,7 +60,7 @@ class MasterSlaveReplication implements ReplicationConnectionInterface /** * {@inheritdoc} */ - public function add(SingleConnectionInterface $connection) + public function add(NodeConnectionInterface $connection) { $alias = $connection->getParameters()->alias; @@ -75,7 +76,7 @@ class MasterSlaveReplication implements ReplicationConnectionInterface /** * {@inheritdoc} */ - public function remove(SingleConnectionInterface $connection) + public function remove(NodeConnectionInterface $connection) { if ($connection->getParameters()->alias === 'master') { $this->master = null; @@ -142,7 +143,7 @@ class MasterSlaveReplication implements ReplicationConnectionInterface { $this->check(); - if (!$connection instanceof SingleConnectionInterface) { + if (!$connection instanceof NodeConnectionInterface) { $connection = $this->getConnectionById($connection); } if ($connection !== $this->master && !in_array($connection, $this->slaves, true)) { @@ -189,7 +190,7 @@ class MasterSlaveReplication implements ReplicationConnectionInterface /** * Returns a random slave. * - * @return SingleConnectionInterface + * @return NodeConnectionInterface */ protected function pickSlave() { diff --git a/lib/Predis/Connection/PredisCluster.php b/lib/Predis/Connection/Aggregate/PredisCluster.php similarity index 93% rename from lib/Predis/Connection/PredisCluster.php rename to lib/Predis/Connection/Aggregate/PredisCluster.php index 3926dfe1..d254a19b 100644 --- a/lib/Predis/Connection/PredisCluster.php +++ b/lib/Predis/Connection/Aggregate/PredisCluster.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Predis\Connection; +namespace Predis\Connection\Aggregate; use ArrayIterator; use Countable; @@ -20,6 +20,7 @@ use Predis\Cluster\StrategyInterface as ClusterStrategyInterface; use Predis\Cluster\Distributor\DistributorInterface; use Predis\Cluster\Distributor\HashRing; use Predis\Command\CommandInterface; +use Predis\Connection\NodeConnectionInterface; /** * Abstraction for a cluster of aggregate connections to various Redis servers @@ -28,7 +29,7 @@ use Predis\Command\CommandInterface; * @author Daniele Alessandri * @todo Add the ability to remove connections from pool. */ -class PredisCluster implements ClusterConnectionInterface, IteratorAggregate, Countable +class PredisCluster implements ClusterInterface, IteratorAggregate, Countable { private $pool; private $strategy; @@ -83,7 +84,7 @@ class PredisCluster implements ClusterConnectionInterface, IteratorAggregate, Co /** * {@inheritdoc} */ - public function add(SingleConnectionInterface $connection) + public function add(NodeConnectionInterface $connection) { $parameters = $connection->getParameters(); @@ -100,7 +101,7 @@ class PredisCluster implements ClusterConnectionInterface, IteratorAggregate, Co /** * {@inheritdoc} */ - public function remove(SingleConnectionInterface $connection) + public function remove(NodeConnectionInterface $connection) { if (($id = array_search($connection, $this->pool, true)) !== false) { unset($this->pool[$id]); @@ -156,8 +157,8 @@ class PredisCluster implements ClusterConnectionInterface, IteratorAggregate, Co /** * Retrieves a connection instance from the cluster using a key. * - * @param string $key Key string. - * @return SingleConnectionInterface + * @param string $key Key string. + * @return NodeConnectionInterface */ public function getConnectionByKey($key) { diff --git a/lib/Predis/Connection/RedisCluster.php b/lib/Predis/Connection/Aggregate/RedisCluster.php similarity index 92% rename from lib/Predis/Connection/RedisCluster.php rename to lib/Predis/Connection/Aggregate/RedisCluster.php index f0c9e49d..6327d8e8 100644 --- a/lib/Predis/Connection/RedisCluster.php +++ b/lib/Predis/Connection/Aggregate/RedisCluster.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Predis\Connection; +namespace Predis\Connection\Aggregate; use ArrayIterator; use Countable; @@ -19,6 +19,9 @@ use Predis\NotSupportedException; use Predis\Cluster\RedisStrategy as RedisClusterStrategy; use Predis\Command\CommandInterface; use Predis\Command\RawCommand; +use Predis\Connection\NodeConnectionInterface; +use Predis\Connection\Factory; +use Predis\Connection\FactoryInterface; use Predis\Response\ErrorInterface as ErrorResponseInterface; /** @@ -43,7 +46,7 @@ use Predis\Response\ErrorInterface as ErrorResponseInterface; * * @author Daniele Alessandri */ -class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Countable +class RedisCluster implements ClusterInterface, IteratorAggregate, Countable { private $askClusterNodes = false; private $defaultParameters = array(); @@ -99,7 +102,7 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou /** * {@inheritdoc} */ - public function add(SingleConnectionInterface $connection) + public function add(NodeConnectionInterface $connection) { $this->pool[(string) $connection] = $connection; unset($this->slotsMap); @@ -108,7 +111,7 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou /** * {@inheritdoc} */ - public function remove(SingleConnectionInterface $connection) + public function remove(NodeConnectionInterface $connection) { if (false !== $id = array_search($connection, $this->pool, true)) { unset( @@ -212,9 +215,9 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou /** * Pre-associates a connection to a slots range to avoid runtime guessing. * - * @param int $first Initial slot of the range. - * @param int $last Last slot of the range. - * @param SingleConnectionInterface|string $connection ID or connection instance. + * @param int $first Initial slot of the range. + * @param int $last Last slot of the range. + * @param NodeConnectionInterface|string $connection ID or connection instance. */ public function setSlots($first, $last, $connection) { @@ -259,8 +262,8 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou /** * Creates a new connection instance from the given connection ID. * - * @param string $connectionID Identifier for the connection. - * @return SingleConnectionInterface + * @param string $connectionID Identifier for the connection. + * @return NodeConnectionInterface */ protected function createConnection($connectionID) { @@ -301,8 +304,8 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou /** * Returns the connection currently associated to a given slot. * - * @param int $slot Slot index. - * @return SingleConnectionInterface + * @param int $slot Slot index. + * @return NodeConnectionInterface */ public function getConnectionBySlot($slot) { @@ -337,7 +340,7 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou /** * Returns a random connection from the pool. * - * @return SingleConnectionInterface + * @return NodeConnectionInterface */ protected function getRandomConnection() { @@ -350,10 +353,10 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou * Permanently associates the connection instance to a new slot. * The connection is added to the connections pool if not yet included. * - * @param SingleConnectionInterface $connection Connection instance. - * @param int $slot Target slot index. + * @param NodeConnectionInterface $connection Connection instance. + * @param int $slot Target slot index. */ - protected function move(SingleConnectionInterface $connection, $slot) + protected function move(NodeConnectionInterface $connection, $slot) { $this->pool[(string) $connection] = $connection; $this->slots[(int) $slot] = $connection; diff --git a/lib/Predis/Connection/ReplicationConnectionInterface.php b/lib/Predis/Connection/Aggregate/ReplicationInterface.php similarity index 74% rename from lib/Predis/Connection/ReplicationConnectionInterface.php rename to lib/Predis/Connection/Aggregate/ReplicationInterface.php index 32747897..5e5b82f4 100644 --- a/lib/Predis/Connection/ReplicationConnectionInterface.php +++ b/lib/Predis/Connection/Aggregate/ReplicationInterface.php @@ -9,14 +9,16 @@ * file that was distributed with this source code. */ -namespace Predis\Connection; +namespace Predis\Connection\Aggregate; + +use Predis\Connection\AggregateConnectionInterface; /** * Defines a group of Redis nodes in a master / slave replication setup. * * @author Daniele Alessandri */ -interface ReplicationConnectionInterface extends AggregateConnectionInterface +interface ReplicationInterface extends AggregateConnectionInterface { /** * Switches the internal connection instance in use. @@ -29,21 +31,21 @@ interface ReplicationConnectionInterface extends AggregateConnectionInterface * Returns the connection instance currently in use by the aggregate * connection. * - * @return SingleConnectionInterface + * @return Predis\Connection\NodeConnectionInterface */ public function getCurrent(); /** * Returns the connection instance for the master Redis node. * - * @return SingleConnectionInterface + * @return Predis\Connection\NodeConnectionInterface */ public function getMaster(); /** * Returns a list of connection instances to slave nodes. * - * @return SingleConnectionInterface + * @return Predis\Connection\NodeConnectionInterface */ public function getSlaves(); } diff --git a/lib/Predis/Connection/AggregateConnectionInterface.php b/lib/Predis/Connection/AggregateConnectionInterface.php index 583934a2..d42c15da 100644 --- a/lib/Predis/Connection/AggregateConnectionInterface.php +++ b/lib/Predis/Connection/AggregateConnectionInterface.php @@ -24,31 +24,31 @@ interface AggregateConnectionInterface extends ConnectionInterface /** * Adds a connection instance to the aggregate connection. * - * @param SingleConnectionInterface $connection Connection instance. + * @param NodeConnectionInterface $connection Connection instance. */ - public function add(SingleConnectionInterface $connection); + public function add(NodeConnectionInterface $connection); /** * Removes the specified connection instance from the aggregate connection. * - * @param SingleConnectionInterface $connection Connection instance. - * @return bool Returns true if the connection was in the pool. + * @param NodeConnectionInterface $connection Connection instance. + * @return bool Returns true if the connection was in the pool. */ - public function remove(SingleConnectionInterface $connection); + public function remove(NodeConnectionInterface $connection); /** * Returns the connection instance in charge for the given command. * - * @param CommandInterface $command Command instance. - * @return SingleConnectionInterface + * @param CommandInterface $command Command instance. + * @return NodeConnectionInterface */ public function getConnection(CommandInterface $command); /** * Returns a connection instance from the aggregate connection by its alias. * - * @param string $connectionID Connection alias. - * @return SingleConnectionInterface + * @param string $connectionID Connection alias. + * @return NodeConnectionInterface */ public function getConnectionById($connectionID); } diff --git a/lib/Predis/Connection/ComposableConnectionInterface.php b/lib/Predis/Connection/CompositeConnectionInterface.php similarity index 93% rename from lib/Predis/Connection/ComposableConnectionInterface.php rename to lib/Predis/Connection/CompositeConnectionInterface.php index d141a8ca..db4bb353 100644 --- a/lib/Predis/Connection/ComposableConnectionInterface.php +++ b/lib/Predis/Connection/CompositeConnectionInterface.php @@ -17,7 +17,7 @@ namespace Predis\Connection; * * @author Daniele Alessandri */ -interface ComposableConnectionInterface extends SingleConnectionInterface +interface CompositeConnectionInterface extends NodeConnectionInterface { /** * Returns the protocol processor used by the connection. diff --git a/lib/Predis/Connection/ComposableStreamConnection.php b/lib/Predis/Connection/CompositeStreamConnection.php similarity index 96% rename from lib/Predis/Connection/ComposableStreamConnection.php rename to lib/Predis/Connection/CompositeStreamConnection.php index 7ff1ec13..85187703 100644 --- a/lib/Predis/Connection/ComposableStreamConnection.php +++ b/lib/Predis/Connection/CompositeStreamConnection.php @@ -22,7 +22,7 @@ use Predis\Protocol\Text\ProtocolProcessor as TextProtocolProcessor; * * @author Daniele Alessandri */ -class ComposableStreamConnection extends StreamConnection implements ComposableConnectionInterface +class CompositeStreamConnection extends StreamConnection implements CompositeConnectionInterface { protected $protocol; diff --git a/lib/Predis/Connection/Factory.php b/lib/Predis/Connection/Factory.php index 047c26b5..ccba81a4 100644 --- a/lib/Predis/Connection/Factory.php +++ b/lib/Predis/Connection/Factory.php @@ -31,7 +31,7 @@ class Factory implements FactoryInterface /** * Checks if the provided argument represents a valid connection class - * implementing Predis\Connection\SingleConnectionInterface. Optionally, + * implementing Predis\Connection\NodeConnectionInterface. Optionally, * callable objects are used for lazy initialization of connection objects. * * @param mixed $initializer FQN of a connection class or a callable for lazy initialization. @@ -45,7 +45,7 @@ class Factory implements FactoryInterface $class = new ReflectionClass($initializer); - if (!$class->isSubclassOf('Predis\Connection\SingleConnectionInterface')) { + if (!$class->isSubclassOf('Predis\Connection\NodeConnectionInterface')) { throw new InvalidArgumentException( 'A connection initializer must be a valid connection class or a callable object.' ); @@ -94,10 +94,10 @@ class Factory implements FactoryInterface $this->prepareConnection($connection); } - if (!$connection instanceof SingleConnectionInterface) { + if (!$connection instanceof NodeConnectionInterface) { throw new UnexpectedValueException( "Objects returned by connection initializers must implement ". - "'Predis\Connection\SingleConnectionInterface'." + "'Predis\Connection\NodeConnectionInterface'." ); } @@ -110,16 +110,16 @@ class Factory implements FactoryInterface public function aggregate(AggregateConnectionInterface $connection, array $parameters) { foreach ($parameters as $node) { - $connection->add($node instanceof SingleConnectionInterface ? $node : $this->create($node)); + $connection->add($node instanceof NodeConnectionInterface ? $node : $this->create($node)); } } /** * Prepares a connection instance after its initialization. * - * @param SingleConnectionInterface $connection Connection instance. + * @param NodeConnectionInterface $connection Connection instance. */ - protected function prepareConnection(SingleConnectionInterface $connection) + protected function prepareConnection(NodeConnectionInterface $connection) { $parameters = $connection->getParameters(); diff --git a/lib/Predis/Connection/FactoryInterface.php b/lib/Predis/Connection/FactoryInterface.php index 3cd5e905..16602157 100644 --- a/lib/Predis/Connection/FactoryInterface.php +++ b/lib/Predis/Connection/FactoryInterface.php @@ -36,8 +36,8 @@ interface FactoryInterface /** * Creates a new connection object. * - * @param mixed $parameters Initialization parameters for the connection. - * @return SingleConnectionInterface + * @param mixed $parameters Initialization parameters for the connection. + * @return NodeConnectionInterface */ public function create($parameters); diff --git a/lib/Predis/Connection/SingleConnectionInterface.php b/lib/Predis/Connection/NodeConnectionInterface.php similarity index 95% rename from lib/Predis/Connection/SingleConnectionInterface.php rename to lib/Predis/Connection/NodeConnectionInterface.php index b935ee19..665b862c 100644 --- a/lib/Predis/Connection/SingleConnectionInterface.php +++ b/lib/Predis/Connection/NodeConnectionInterface.php @@ -18,7 +18,7 @@ use Predis\Command\CommandInterface; * * @author Daniele Alessandri */ -interface SingleConnectionInterface extends ConnectionInterface +interface NodeConnectionInterface extends ConnectionInterface { /** * Returns a string representation of the connection. diff --git a/lib/Predis/Connection/WebdisConnection.php b/lib/Predis/Connection/WebdisConnection.php index 6a03cb1c..1581a5a6 100644 --- a/lib/Predis/Connection/WebdisConnection.php +++ b/lib/Predis/Connection/WebdisConnection.php @@ -44,7 +44,7 @@ use Predis\Response\Status as StatusResponse; * @link http://github.com/seppo0010/phpiredis * @author Daniele Alessandri */ -class WebdisConnection implements SingleConnectionInterface +class WebdisConnection implements NodeConnectionInterface { private $parameters; private $resource; diff --git a/lib/Predis/Pipeline/Atomic.php b/lib/Predis/Pipeline/Atomic.php index 316800f4..9e6742bd 100644 --- a/lib/Predis/Pipeline/Atomic.php +++ b/lib/Predis/Pipeline/Atomic.php @@ -15,7 +15,7 @@ use SplQueue; use Predis\ClientException; use Predis\ClientInterface; use Predis\Connection\ConnectionInterface; -use Predis\Connection\SingleConnectionInterface; +use Predis\Connection\NodeConnectionInterface; use Predis\Response\ErrorInterface as ErrorResponseInterface; use Predis\Response\ResponseInterface; use Predis\Response\ServerException; @@ -48,7 +48,7 @@ class Atomic extends Pipeline { $connection = $this->getClient()->getConnection(); - if (!$connection instanceof SingleConnectionInterface) { + if (!$connection instanceof NodeConnectionInterface) { $class = __CLASS__; throw new ClientException("The class '$class' does not support aggregate connections."); diff --git a/lib/Predis/Pipeline/ConnectionErrorProof.php b/lib/Predis/Pipeline/ConnectionErrorProof.php index 1f2183af..f119fb03 100644 --- a/lib/Predis/Pipeline/ConnectionErrorProof.php +++ b/lib/Predis/Pipeline/ConnectionErrorProof.php @@ -14,9 +14,9 @@ namespace Predis\Pipeline; use SplQueue; use Predis\NotSupportedException; use Predis\CommunicationException; -use Predis\Connection\ClusterConnectionInterface; +use Predis\Connection\ClusterInterface; use Predis\Connection\ConnectionInterface; -use Predis\Connection\SingleConnectionInterface; +use Predis\Connection\NodeConnectionInterface; /** * Command pipeline that does not throw exceptions on connection errors, but @@ -40,9 +40,9 @@ class ConnectionErrorProof extends Pipeline */ protected function executePipeline(ConnectionInterface $connection, SplQueue $commands) { - if ($connection instanceof SingleConnectionInterface) { + if ($connection instanceof NodeConnectionInterface) { return $this->executeSingleNode($connection, $commands); - } elseif ($connection instanceof ClusterConnectionInterface) { + } elseif ($connection instanceof ClusterInterface) { return $this->executeCluster($connection, $commands); } else { $class = get_class($connection); @@ -54,7 +54,7 @@ class ConnectionErrorProof extends Pipeline /** * {@inheritdoc} */ - public function executeSingleNode(SingleConnectionInterface $connection, SplQueue $commands) + public function executeSingleNode(NodeConnectionInterface $connection, SplQueue $commands) { $responses = array(); $sizeOfPipe = count($commands); @@ -86,7 +86,7 @@ class ConnectionErrorProof extends Pipeline /** * {@inheritdoc} */ - public function executeCluster(ClusterConnectionInterface $connection, SplQueue $commands) + public function executeCluster(ClusterInterface $connection, SplQueue $commands) { $responses = array(); $sizeOfPipe = count($commands); diff --git a/lib/Predis/Pipeline/Pipeline.php b/lib/Predis/Pipeline/Pipeline.php index 0d15c880..195ce1f5 100644 --- a/lib/Predis/Pipeline/Pipeline.php +++ b/lib/Predis/Pipeline/Pipeline.php @@ -20,7 +20,7 @@ use Predis\ClientInterface; use Predis\ExecutableContextInterface; use Predis\Command\CommandInterface; use Predis\Connection\ConnectionInterface; -use Predis\Connection\ReplicationConnectionInterface; +use Predis\Connection\Aggregate\ReplicationInterface; use Predis\Response\ErrorInterface as ErrorResponseInterface; use Predis\Response\ResponseInterface; use Predis\Response\ServerException; @@ -109,7 +109,7 @@ class Pipeline implements BasicClientInterface, ExecutableContextInterface { $connection = $this->getClient()->getConnection(); - if ($connection instanceof ReplicationConnectionInterface) { + if ($connection instanceof ReplicationInterface) { $connection->switchTo('master'); } diff --git a/lib/Predis/Protocol/ProtocolProcessorInterface.php b/lib/Predis/Protocol/ProtocolProcessorInterface.php index 795c55a6..d0845a21 100644 --- a/lib/Predis/Protocol/ProtocolProcessorInterface.php +++ b/lib/Predis/Protocol/ProtocolProcessorInterface.php @@ -12,7 +12,7 @@ namespace Predis\Protocol; use Predis\Command\CommandInterface; -use Predis\Connection\ComposableConnectionInterface; +use Predis\Connection\CompositeConnectionInterface; /** * Defines a pluggable protocol processor capable of serializing commands and @@ -25,16 +25,16 @@ interface ProtocolProcessorInterface /** * Writes a request over a connection to Redis. * - * @param ComposableConnectionInterface $connection Redis connection. - * @param CommandInterface $command Command instance. + * @param CompositeConnectionInterface $connection Redis connection. + * @param CommandInterface $command Command instance. */ - public function write(ComposableConnectionInterface $connection, CommandInterface $command); + public function write(CompositeConnectionInterface $connection, CommandInterface $command); /** * Reads a response from a connection to Redis. * - * @param ComposableConnectionInterface $connection Redis connection. + * @param CompositeConnectionInterface $connection Redis connection. * @return mixed */ - public function read(ComposableConnectionInterface $connection); + public function read(CompositeConnectionInterface $connection); } diff --git a/lib/Predis/Protocol/ResponseReaderInterface.php b/lib/Predis/Protocol/ResponseReaderInterface.php index ce25b7e2..5ead1d6f 100644 --- a/lib/Predis/Protocol/ResponseReaderInterface.php +++ b/lib/Predis/Protocol/ResponseReaderInterface.php @@ -11,7 +11,7 @@ namespace Predis\Protocol; -use Predis\Connection\ComposableConnectionInterface; +use Predis\Connection\CompositeConnectionInterface; /** * Defines a pluggable reader capable of parsing responses returned by Redis and @@ -24,8 +24,8 @@ interface ResponseReaderInterface /** * Reads a response from a connection to Redis. * - * @param ComposableConnectionInterface $connection Redis connection. + * @param CompositeConnectionInterface $connection Redis connection. * @return mixed */ - public function read(ComposableConnectionInterface $connection); + public function read(CompositeConnectionInterface $connection); } diff --git a/lib/Predis/Protocol/Text/ComposableProtocolProcessor.php b/lib/Predis/Protocol/Text/ComposableProtocolProcessor.php index c6e1a3f7..41a4d09b 100644 --- a/lib/Predis/Protocol/Text/ComposableProtocolProcessor.php +++ b/lib/Predis/Protocol/Text/ComposableProtocolProcessor.php @@ -12,7 +12,7 @@ namespace Predis\Protocol\Text; use Predis\Command\CommandInterface; -use Predis\Connection\ComposableConnectionInterface; +use Predis\Connection\CompositeConnectionInterface; use Predis\Protocol\ProtocolProcessorInterface; use Predis\Protocol\RequestSerializerInterface; use Predis\Protocol\ResponseReaderInterface; @@ -44,7 +44,7 @@ class ComposableProtocolProcessor implements ProtocolProcessorInterface /** * {@inheritdoc} */ - public function write(ComposableConnectionInterface $connection, CommandInterface $command) + public function write(CompositeConnectionInterface $connection, CommandInterface $command) { $connection->writeBuffer($this->serializer->serialize($command)); } @@ -52,7 +52,7 @@ class ComposableProtocolProcessor implements ProtocolProcessorInterface /** * {@inheritdoc} */ - public function read(ComposableConnectionInterface $connection) + public function read(CompositeConnectionInterface $connection) { return $this->reader->read($connection); } diff --git a/lib/Predis/Protocol/Text/Handler/BulkResponse.php b/lib/Predis/Protocol/Text/Handler/BulkResponse.php index a5dbaab9..410ded19 100644 --- a/lib/Predis/Protocol/Text/Handler/BulkResponse.php +++ b/lib/Predis/Protocol/Text/Handler/BulkResponse.php @@ -12,7 +12,7 @@ namespace Predis\Protocol\Text\Handler; use Predis\CommunicationException; -use Predis\Connection\ComposableConnectionInterface; +use Predis\Connection\CompositeConnectionInterface; use Predis\Protocol\ProtocolException; /** @@ -27,7 +27,7 @@ class BulkResponse implements ResponseHandlerInterface /** * {@inheritdoc} */ - public function handle(ComposableConnectionInterface $connection, $payload) + public function handle(CompositeConnectionInterface $connection, $payload) { $length = (int) $payload; diff --git a/lib/Predis/Protocol/Text/Handler/ErrorResponse.php b/lib/Predis/Protocol/Text/Handler/ErrorResponse.php index 6eb1152e..ed97203a 100644 --- a/lib/Predis/Protocol/Text/Handler/ErrorResponse.php +++ b/lib/Predis/Protocol/Text/Handler/ErrorResponse.php @@ -11,7 +11,7 @@ namespace Predis\Protocol\Text\Handler; -use Predis\Connection\ComposableConnectionInterface; +use Predis\Connection\CompositeConnectionInterface; use Predis\Response\Error; /** @@ -26,7 +26,7 @@ class ErrorResponse implements ResponseHandlerInterface /** * {@inheritdoc} */ - public function handle(ComposableConnectionInterface $connection, $payload) + public function handle(CompositeConnectionInterface $connection, $payload) { return new Error($payload); } diff --git a/lib/Predis/Protocol/Text/Handler/IntegerResponse.php b/lib/Predis/Protocol/Text/Handler/IntegerResponse.php index 78eb8047..e176c1f7 100644 --- a/lib/Predis/Protocol/Text/Handler/IntegerResponse.php +++ b/lib/Predis/Protocol/Text/Handler/IntegerResponse.php @@ -12,7 +12,7 @@ namespace Predis\Protocol\Text\Handler; use Predis\CommunicationException; -use Predis\Connection\ComposableConnectionInterface; +use Predis\Connection\CompositeConnectionInterface; use Predis\Protocol\ProtocolException; /** @@ -27,7 +27,7 @@ class IntegerResponse implements ResponseHandlerInterface /** * {@inheritdoc} */ - public function handle(ComposableConnectionInterface $connection, $payload) + public function handle(CompositeConnectionInterface $connection, $payload) { if (is_numeric($payload)) { return (int) $payload; diff --git a/lib/Predis/Protocol/Text/Handler/MultiBulkResponse.php b/lib/Predis/Protocol/Text/Handler/MultiBulkResponse.php index e6253e60..00e5ee02 100644 --- a/lib/Predis/Protocol/Text/Handler/MultiBulkResponse.php +++ b/lib/Predis/Protocol/Text/Handler/MultiBulkResponse.php @@ -12,7 +12,7 @@ namespace Predis\Protocol\Text\Handler; use Predis\CommunicationException; -use Predis\Connection\ComposableConnectionInterface; +use Predis\Connection\CompositeConnectionInterface; use Predis\Protocol\ProtocolException; /** @@ -27,7 +27,7 @@ class MultiBulkResponse implements ResponseHandlerInterface /** * {@inheritdoc} */ - public function handle(ComposableConnectionInterface $connection, $payload) + public function handle(CompositeConnectionInterface $connection, $payload) { $length = (int) $payload; diff --git a/lib/Predis/Protocol/Text/Handler/ResponseHandlerInterface.php b/lib/Predis/Protocol/Text/Handler/ResponseHandlerInterface.php index b61ca1d8..29316da8 100644 --- a/lib/Predis/Protocol/Text/Handler/ResponseHandlerInterface.php +++ b/lib/Predis/Protocol/Text/Handler/ResponseHandlerInterface.php @@ -11,7 +11,7 @@ namespace Predis\Protocol\Text\Handler; -use Predis\Connection\ComposableConnectionInterface; +use Predis\Connection\CompositeConnectionInterface; /** * Defines a pluggable handler used to parse a particular type of response. @@ -24,9 +24,9 @@ interface ResponseHandlerInterface * Deserializes a response returned by Redis and reads more data from the * connection if needed. * - * @param ComposableConnectionInterface $connection Redis connection. - * @param string $payload String payload. + * @param CompositeConnectionInterface $connection Redis connection. + * @param string $payload String payload. * @return mixed */ - public function handle(ComposableConnectionInterface $connection, $payload); + public function handle(CompositeConnectionInterface $connection, $payload); } diff --git a/lib/Predis/Protocol/Text/Handler/StatusResponse.php b/lib/Predis/Protocol/Text/Handler/StatusResponse.php index ef156137..3a61e84b 100644 --- a/lib/Predis/Protocol/Text/Handler/StatusResponse.php +++ b/lib/Predis/Protocol/Text/Handler/StatusResponse.php @@ -11,7 +11,7 @@ namespace Predis\Protocol\Text\Handler; -use Predis\Connection\ComposableConnectionInterface; +use Predis\Connection\CompositeConnectionInterface; use Predis\Response\Status; /** @@ -27,7 +27,7 @@ class StatusResponse implements ResponseHandlerInterface /** * {@inheritdoc} */ - public function handle(ComposableConnectionInterface $connection, $payload) + public function handle(CompositeConnectionInterface $connection, $payload) { return Status::get($payload); } diff --git a/lib/Predis/Protocol/Text/Handler/StreamableMultiBulkResponse.php b/lib/Predis/Protocol/Text/Handler/StreamableMultiBulkResponse.php index a2d66b7f..7a2988fc 100644 --- a/lib/Predis/Protocol/Text/Handler/StreamableMultiBulkResponse.php +++ b/lib/Predis/Protocol/Text/Handler/StreamableMultiBulkResponse.php @@ -12,7 +12,7 @@ namespace Predis\Protocol\Text\Handler; use Predis\CommunicationException; -use Predis\Connection\ComposableConnectionInterface; +use Predis\Connection\CompositeConnectionInterface; use Predis\Response\Iterator\MultiBulk as MultiBulkIterator; use Predis\Protocol\ProtocolException; @@ -31,7 +31,7 @@ class StreamableMultiBulkResponse implements ResponseHandlerInterface /** * {@inheritdoc} */ - public function handle(ComposableConnectionInterface $connection, $payload) + public function handle(CompositeConnectionInterface $connection, $payload) { $length = (int) $payload; diff --git a/lib/Predis/Protocol/Text/ProtocolProcessor.php b/lib/Predis/Protocol/Text/ProtocolProcessor.php index d9a35d03..d59d0122 100644 --- a/lib/Predis/Protocol/Text/ProtocolProcessor.php +++ b/lib/Predis/Protocol/Text/ProtocolProcessor.php @@ -13,7 +13,7 @@ namespace Predis\Protocol\Text; use Predis\CommunicationException; use Predis\Command\CommandInterface; -use Predis\Connection\ComposableConnectionInterface; +use Predis\Connection\CompositeConnectionInterface; use Predis\Protocol\ProtocolException; use Predis\Protocol\ProtocolProcessorInterface; use Predis\Response\Status as StatusResponse; @@ -43,7 +43,7 @@ class ProtocolProcessor implements ProtocolProcessorInterface /** * {@inheritdoc} */ - public function write(ComposableConnectionInterface $connection, CommandInterface $command) + public function write(CompositeConnectionInterface $connection, CommandInterface $command) { $request = $this->serializer->serialize($command); $connection->writeBuffer($request); @@ -52,7 +52,7 @@ class ProtocolProcessor implements ProtocolProcessorInterface /** * {@inheritdoc} */ - public function read(ComposableConnectionInterface $connection) + public function read(CompositeConnectionInterface $connection) { $chunk = $connection->readLine(); $prefix = $chunk[0]; diff --git a/lib/Predis/Protocol/Text/ResponseReader.php b/lib/Predis/Protocol/Text/ResponseReader.php index 0bdf246b..90785e37 100644 --- a/lib/Predis/Protocol/Text/ResponseReader.php +++ b/lib/Predis/Protocol/Text/ResponseReader.php @@ -12,7 +12,7 @@ namespace Predis\Protocol\Text; use Predis\CommunicationException; -use Predis\Connection\ComposableConnectionInterface; +use Predis\Connection\CompositeConnectionInterface; use Predis\Protocol\ProtocolException; use Predis\Protocol\ResponseReaderInterface; @@ -77,7 +77,7 @@ class ResponseReader implements ResponseReaderInterface /** * {@inheritdoc} */ - public function read(ComposableConnectionInterface $connection) + public function read(CompositeConnectionInterface $connection) { $header = $connection->readLine(); @@ -100,10 +100,10 @@ class ResponseReader implements ResponseReaderInterface * Handles protocol errors generated while reading responses from a * connection. * - * @param ComposableConnectionInterface $connection Redis connection that generated the error. - * @param string $message Error message. + * @param CompositeConnectionInterface $connection Redis connection that generated the error. + * @param string $message Error message. */ - protected function onProtocolError(ComposableConnectionInterface $connection, $message) + protected function onProtocolError(CompositeConnectionInterface $connection, $message) { CommunicationException::handle( new ProtocolException($connection, $message) diff --git a/lib/Predis/Response/Iterator/MultiBulk.php b/lib/Predis/Response/Iterator/MultiBulk.php index 12189f3e..bec5d43d 100644 --- a/lib/Predis/Response/Iterator/MultiBulk.php +++ b/lib/Predis/Response/Iterator/MultiBulk.php @@ -11,7 +11,7 @@ namespace Predis\Response\Iterator; -use Predis\Connection\SingleConnectionInterface; +use Predis\Connection\NodeConnectionInterface; /** * Streamable multibulk response. @@ -23,10 +23,10 @@ class MultiBulk extends MultiBulkIterator private $connection; /** - * @param SingleConnectionInterface $connection Connection to Redis. - * @param int $size Number of elements of the multibulk response. + * @param NodeConnectionInterface $connection Connection to Redis. + * @param int $size Number of elements of the multibulk response. */ - public function __construct(SingleConnectionInterface $connection, $size) + public function __construct(NodeConnectionInterface $connection, $size) { $this->connection = $connection; $this->size = $size; diff --git a/lib/Predis/Transaction/MultiExec.php b/lib/Predis/Transaction/MultiExec.php index 6b3678c3..8813b68a 100644 --- a/lib/Predis/Transaction/MultiExec.php +++ b/lib/Predis/Transaction/MultiExec.php @@ -424,7 +424,7 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface { // 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. + // will return a Predis\Connection\NodeConnectionInterface instance. CommunicationException::handle(new ProtocolException( $this->client->getConnection(), $message )); diff --git a/tests/Predis/ClientTest.php b/tests/Predis/ClientTest.php index e69f3cdc..41b8743f 100644 --- a/tests/Predis/ClientTest.php +++ b/tests/Predis/ClientTest.php @@ -30,7 +30,7 @@ class ClientTest extends PredisTestCase $client = new Client(); $connection = $client->getConnection(); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); + $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection); $parameters = $connection->getParameters(); $this->assertSame($parameters->host, '127.0.0.1'); @@ -50,7 +50,7 @@ class ClientTest extends PredisTestCase $client = new Client(null); $connection = $client->getConnection(); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); + $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection); $parameters = $connection->getParameters(); $this->assertSame($parameters->host, '127.0.0.1'); @@ -70,7 +70,7 @@ class ClientTest extends PredisTestCase $client = new Client(null, null); $connection = $client->getConnection(); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); + $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection); $parameters = $connection->getParameters(); $this->assertSame($parameters->host, '127.0.0.1'); @@ -106,7 +106,7 @@ class ClientTest extends PredisTestCase $client = new Client($arg1); - $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $client->getConnection()); + $this->assertInstanceOf('Predis\Connection\Aggregate\ClusterInterface', $client->getConnection()); } /** @@ -128,7 +128,7 @@ class ClientTest extends PredisTestCase { $client = new Client($arg1 = array('tcp://localhost:7000', 'tcp://localhost:7001')); - $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $client->getConnection()); + $this->assertInstanceOf('Predis\Connection\Aggregate\ClusterInterface', $client->getConnection()); } /** @@ -136,12 +136,12 @@ class ClientTest extends PredisTestCase */ public function testConstructorWithArrayOfConnectionsArgument() { - $connection1 = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection2 = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection1 = $this->getMock('Predis\Connection\NodeConnectionInterface'); + $connection2 = $this->getMock('Predis\Connection\NodeConnectionInterface'); $client = new Client(array($connection1, $connection2)); - $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $cluster = $client->getConnection()); + $this->assertInstanceOf('Predis\Connection\Aggregate\ClusterInterface', $cluster = $client->getConnection()); $this->assertSame($connection1, $cluster->getConnectionById(0)); $this->assertSame($connection2, $cluster->getConnectionById(1)); } @@ -156,7 +156,7 @@ class ClientTest extends PredisTestCase $client = new Client($connection); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $client->getConnection()); + $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $client->getConnection()); $this->assertSame($connection, $client->getConnection()); $parameters = $client->getConnection()->getParameters(); @@ -169,14 +169,14 @@ class ClientTest extends PredisTestCase */ public function testConstructorWithClusterArgument() { - $cluster = new Connection\PredisCluster(); + $cluster = new Connection\Aggregate\PredisCluster(); $factory = new Connection\Factory(); $factory->aggregate($cluster, array('tcp://localhost:7000', 'tcp://localhost:7001')); $client = new Client($cluster); - $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $client->getConnection()); + $this->assertInstanceOf('Predis\Connection\Aggregate\ClusterInterface', $client->getConnection()); $this->assertSame($cluster, $client->getConnection()); } @@ -185,14 +185,14 @@ class ClientTest extends PredisTestCase */ public function testConstructorWithReplicationArgument() { - $replication = new Connection\MasterSlaveReplication(); + $replication = new Connection\Aggregate\MasterSlaveReplication(); $factory = new Connection\Factory(); $factory->aggregate($replication, array('tcp://host1?alias=master', 'tcp://host2?alias=slave')); $client = new Client($replication); - $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $client->getConnection()); + $this->assertInstanceOf('Predis\Connection\Aggregate\ReplicationInterface', $client->getConnection()); $this->assertSame($replication, $client->getConnection()); } @@ -257,7 +257,7 @@ class ClientTest extends PredisTestCase $arg2 = array('replication' => true); $client = new Client($arg1, $arg2); - $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $connection = $client->getConnection()); + $this->assertInstanceOf('Predis\Connection\Aggregate\ReplicationInterface', $connection = $client->getConnection()); $this->assertSame('host1', $connection->getConnectionById('master')->getParameters()->host); $this->assertSame('host2', $connection->getConnectionById('slave')->getParameters()->host); } @@ -584,9 +584,9 @@ class ClientTest extends PredisTestCase { $client = new Client(array('tcp://host1?alias=node01', 'tcp://host2?alias=node02')); - $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $cluster = $client->getConnection()); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $node01 = $client->getConnectionById('node01')); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $node02 = $client->getConnectionById('node02')); + $this->assertInstanceOf('Predis\Connection\Aggregate\ClusterInterface', $cluster = $client->getConnection()); + $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $node01 = $client->getConnectionById('node01')); + $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $node02 = $client->getConnectionById('node02')); $this->assertSame('host1', $node01->getParameters()->host); $this->assertSame('host2', $node02->getParameters()->host); @@ -611,9 +611,9 @@ class ClientTest extends PredisTestCase { $client = new Client(array('tcp://host1?alias=node01', 'tcp://host2?alias=node02'), array('prefix' => 'pfx:')); - $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $cluster = $client->getConnection()); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $node01 = $client->getConnectionById('node01')); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $node02 = $client->getConnectionById('node02')); + $this->assertInstanceOf('Predis\Connection\Aggregate\ClusterInterface', $cluster = $client->getConnection()); + $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $node01 = $client->getConnectionById('node01')); + $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $node02 = $client->getConnectionById('node02')); $clientNode02 = $client->getClientFor('node02'); @@ -684,7 +684,7 @@ class ClientTest extends PredisTestCase */ public function testPubSubLoopWithArrayReturnsPubSubConsumerWithOptions() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $options = array('subscribe' => 'channel'); $client = new Client($connection); @@ -709,7 +709,7 @@ class ClientTest extends PredisTestCase $message = array('subscribe', 'channel', 0); $options = array('subscribe' => 'channel'); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->once()) ->method('read') ->will($this->returnValue($message)); @@ -762,7 +762,7 @@ class ClientTest extends PredisTestCase // here is not the point. $options = array('cas' => true, 'retry' => 3); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->once()) ->method('executeCommand') ->will($this->returnValue(new Response\Status('QUEUED'))); @@ -785,7 +785,7 @@ class ClientTest extends PredisTestCase */ public function testMonitorReturnsMonitorConsumer() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $client = new Client($connection); $this->assertInstanceOf('Predis\Monitor\Consumer', $monitor = $client->monitor()); @@ -805,7 +805,7 @@ class ClientTest extends PredisTestCase ->with('OK') ->will($this->returnValue(true)); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->at(0)) ->method('executeCommand') ->with($command) diff --git a/tests/Predis/CommunicationExceptionTest.php b/tests/Predis/CommunicationExceptionTest.php index 1d88cd79..64b78371 100644 --- a/tests/Predis/CommunicationExceptionTest.php +++ b/tests/Predis/CommunicationExceptionTest.php @@ -62,7 +62,7 @@ class CommunicationExceptionTest extends PredisTestCase */ public function testCommunicationExceptionHandling() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->once())->method('isConnected')->will($this->returnValue(true)); $connection->expects($this->once())->method('disconnect'); @@ -78,8 +78,8 @@ class CommunicationExceptionTest extends PredisTestCase /** * Returns a mocked connection instance. * - * @param mixed $parameters Connection parameters. - * @return Connection\SingleConnectionInterface + * @param mixed $parameters Connection parameters. + * @return Connection\NodeConnectionInterface */ protected function getMockedConnectionBase($parameters = null) { @@ -97,14 +97,14 @@ class CommunicationExceptionTest extends PredisTestCase /** * Returns a connection exception instance. * - * @param Connection\SingleConnectionInterface $connection Connection instance. - * @param string $message Exception message. - * @param int $code Exception code. - * @param \Exception $inner Inner exception. + * @param Connection\NodeConnectionInterface $connection Connection instance. + * @param string $message Exception message. + * @param int $code Exception code. + * @param \Exception $inner Inner exception. * @return \Exception */ protected function getException( - Connection\SingleConnectionInterface $connection, + Connection\NodeConnectionInterface $connection, $message, $code = 0, \Exception $inner = null diff --git a/tests/Predis/Configuration/ClusterOptionTest.php b/tests/Predis/Configuration/ClusterOptionTest.php index 7f5c4671..f0923e37 100644 --- a/tests/Predis/Configuration/ClusterOptionTest.php +++ b/tests/Predis/Configuration/ClusterOptionTest.php @@ -26,17 +26,17 @@ class ClusterOptionTest extends PredisTestCase $option = new ClusterOption(); $options = $this->getMock('Predis\Configuration\OptionsInterface'); - $this->assertInstanceOf('Predis\Connection\PredisCluster', $option->getDefault($options)); + $this->assertInstanceOf('Predis\Connection\Aggregate\PredisCluster', $option->getDefault($options)); } /** * @group disconnected */ - public function testAcceptsInstanceOfClusterConnectionInterface() + public function testAcceptsInstanceOfClusterInterface() { $option = new ClusterOption(); $options = $this->getMock('Predis\Configuration\OptionsInterface'); - $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface'); + $cluster = $this->getMock('Predis\Connection\Aggregate\ClusterInterface'); $this->assertSame($cluster, $option->filter($options, $cluster)); } @@ -49,11 +49,11 @@ class ClusterOptionTest extends PredisTestCase $option = new ClusterOption(); $options = $this->getMock('Predis\Configuration\OptionsInterface'); - $this->assertInstanceOf('Predis\Connection\PredisCluster', $option->filter($options, 'predis')); - $this->assertInstanceOf('Predis\Connection\PredisCluster', $option->filter($options, 'predis-cluster')); + $this->assertInstanceOf('Predis\Connection\Aggregate\PredisCluster', $option->filter($options, 'predis')); + $this->assertInstanceOf('Predis\Connection\Aggregate\PredisCluster', $option->filter($options, 'predis-cluster')); - $this->assertInstanceOf('Predis\Connection\RedisCluster', $option->filter($options, 'redis')); - $this->assertInstanceOf('Predis\Connection\RedisCluster', $option->filter($options, 'redis-cluster')); + $this->assertInstanceOf('Predis\Connection\Aggregate\RedisCluster', $option->filter($options, 'redis')); + $this->assertInstanceOf('Predis\Connection\Aggregate\RedisCluster', $option->filter($options, 'redis-cluster')); } /** @@ -64,7 +64,7 @@ class ClusterOptionTest extends PredisTestCase { $option = new ClusterOption(); $options = $this->getMock('Predis\Configuration\OptionsInterface'); - $class = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $class = $this->getMock('Predis\Connection\NodeConnectionInterface'); $option->filter($options, $class); } diff --git a/tests/Predis/Configuration/ConnectionFactoryOptionTest.php b/tests/Predis/Configuration/ConnectionFactoryOptionTest.php index 92e73c61..869e0e9d 100644 --- a/tests/Predis/Configuration/ConnectionFactoryOptionTest.php +++ b/tests/Predis/Configuration/ConnectionFactoryOptionTest.php @@ -39,7 +39,7 @@ class ConnectionFactoryOptionTest extends PredisTestCase $option = new ConnectionFactoryOption(); $options = $this->getMock('Predis\Configuration\OptionsInterface'); - $class = get_class($this->getMock('Predis\Connection\SingleConnectionInterface')); + $class = get_class($this->getMock('Predis\Connection\NodeConnectionInterface')); $value = array('tcp' => $class, 'redis' => $class); $default = $this->getMock('Predis\Connection\FactoryInterface'); diff --git a/tests/Predis/Configuration/OptionsTest.php b/tests/Predis/Configuration/OptionsTest.php index cc37d96d..ac1e7aba 100644 --- a/tests/Predis/Configuration/OptionsTest.php +++ b/tests/Predis/Configuration/OptionsTest.php @@ -29,8 +29,8 @@ class OptionsTest extends PredisTestCase $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); + $this->assertInstanceOf('Predis\Connection\Aggregate\ClusterInterface', $options->cluster); + $this->assertInstanceOf('Predis\Connection\Aggregate\ReplicationInterface', $options->replication); $this->assertTrue($options->exceptions); $this->assertNull($options->prefix); } @@ -45,16 +45,16 @@ class OptionsTest extends PredisTestCase 'profile' => '2.0', 'prefix' => 'prefix:', 'connections' => $this->getMock('Predis\Connection\FactoryInterface'), - 'cluster' => $this->getMock('Predis\Connection\ClusterConnectionInterface'), - 'replication' => $this->getMock('Predis\Connection\ReplicationConnectionInterface'), + 'cluster' => $this->getMock('Predis\Connection\Aggregate\ClusterInterface'), + 'replication' => $this->getMock('Predis\Connection\Aggregate\ReplicationInterface'), )); $this->assertInternalType('bool', $options->exceptions); $this->assertInstanceOf('Predis\Profile\ProfileInterface', $options->profile); $this->assertInstanceOf('Predis\Command\Processor\ProcessorInterface', $options->prefix); $this->assertInstanceOf('Predis\Connection\FactoryInterface', $options->connections); - $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $options->cluster); - $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $options->replication); + $this->assertInstanceOf('Predis\Connection\Aggregate\ClusterInterface', $options->cluster); + $this->assertInstanceOf('Predis\Connection\Aggregate\ReplicationInterface', $options->replication); } /** diff --git a/tests/Predis/Configuration/ReplicationOptionTest.php b/tests/Predis/Configuration/ReplicationOptionTest.php index 4115e972..e3863c1d 100644 --- a/tests/Predis/Configuration/ReplicationOptionTest.php +++ b/tests/Predis/Configuration/ReplicationOptionTest.php @@ -26,8 +26,8 @@ class ReplicationOptionTest extends PredisTestCase $option = new ReplicationOption(); $options = $this->getMock('Predis\Configuration\OptionsInterface'); - $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $option->getDefault($options)); - $this->assertInstanceOf('Predis\Connection\MasterSlaveReplication', $option->getDefault($options)); + $this->assertInstanceOf('Predis\Connection\Aggregate\ReplicationInterface', $option->getDefault($options)); + $this->assertInstanceOf('Predis\Connection\Aggregate\MasterSlaveReplication', $option->getDefault($options)); } /** @@ -40,16 +40,16 @@ class ReplicationOptionTest extends PredisTestCase $this->assertNull($option->filter($options, null)); - $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $option->filter($options, true)); + $this->assertInstanceOf('Predis\Connection\Aggregate\ReplicationInterface', $option->filter($options, true)); $this->assertNull($option->filter($options, false)); - $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $option->filter($options, 1)); + $this->assertInstanceOf('Predis\Connection\Aggregate\ReplicationInterface', $option->filter($options, 1)); $this->assertNull($option->filter($options, 0)); - $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $option->filter($options, 'true')); + $this->assertInstanceOf('Predis\Connection\Aggregate\ReplicationInterface', $option->filter($options, 'true')); $this->assertNull($option->filter($options, 'false')); - $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $option->filter($options, 'on')); + $this->assertInstanceOf('Predis\Connection\Aggregate\ReplicationInterface', $option->filter($options, 'on')); $this->assertNull($option->filter($options, 'off')); } @@ -61,7 +61,7 @@ class ReplicationOptionTest extends PredisTestCase { $option = new ReplicationOption(); $options = $this->getMock('Predis\Configuration\OptionsInterface'); - $value = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $value = $this->getMock('Predis\Connection\NodeConnectionInterface'); $option->filter($options, $value); } diff --git a/tests/Predis/Connection/MasterSlaveReplicationTest.php b/tests/Predis/Connection/Aggregate/MasterSlaveReplicationTest.php similarity index 98% rename from tests/Predis/Connection/MasterSlaveReplicationTest.php rename to tests/Predis/Connection/Aggregate/MasterSlaveReplicationTest.php index c1a40e72..ff8ad53e 100644 --- a/tests/Predis/Connection/MasterSlaveReplicationTest.php +++ b/tests/Predis/Connection/Aggregate/MasterSlaveReplicationTest.php @@ -9,9 +9,10 @@ * file that was distributed with this source code. */ -namespace Predis\Connection; +namespace Predis\Connection\Aggregate; use PredisTestCase; +use Predis\Connection; use Predis\Profile; use Predis\Replication\ReplicationStrategy; @@ -567,17 +568,17 @@ class MasterSlaveReplicationTest extends PredisTestCase // ******************************************************************** // /** - * Returns a base mocked connection from Predis\Connection\SingleConnectionInterface. + * Returns a base mocked connection from Predis\Connection\NodeConnectionInterface. * * @param mixed $parameters Optional parameters. * @return mixed */ protected function getMockConnection($parameters = null) { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); if ($parameters) { - $parameters = Parameters::create($parameters); + $parameters = Connection\Parameters::create($parameters); $hash = "{$parameters->host}:{$parameters->port}"; $connection->expects($this->any()) diff --git a/tests/Predis/Connection/PredisClusterTest.php b/tests/Predis/Connection/Aggregate/PredisClusterTest.php similarity index 96% rename from tests/Predis/Connection/PredisClusterTest.php rename to tests/Predis/Connection/Aggregate/PredisClusterTest.php index e3030af9..5d4db552 100644 --- a/tests/Predis/Connection/PredisClusterTest.php +++ b/tests/Predis/Connection/Aggregate/PredisClusterTest.php @@ -9,9 +9,10 @@ * file that was distributed with this source code. */ -namespace Predis\Connection; +namespace Predis\Connection\Aggregate; use PredisTestCase; +use Predis\Connection; use Predis\Profile; /** @@ -335,13 +336,13 @@ class PredisClusterTest extends PredisTestCase { $ping = Profile\Factory::getDefault()->createCommand('ping', array()); - $connection1 = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection1 = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection1->expects($this->once()) ->method('executeCommand') ->with($ping) ->will($this->returnValue(true)); - $connection2 = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection2 = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection2->expects($this->once()) ->method('executeCommand') ->with($ping) @@ -378,17 +379,17 @@ class PredisClusterTest extends PredisTestCase // ******************************************************************** // /** - * Returns a base mocked connection from Predis\Connection\SingleConnectionInterface. + * Returns a base mocked connection from Predis\Connection\NodeConnectionInterface. * * @param mixed $parameters Optional parameters. * @return mixed */ protected function getMockConnection($parameters = null) { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); if ($parameters) { - $parameters = Parameters::create($parameters); + $parameters = Connection\Parameters::create($parameters); $hash = "{$parameters->host}:{$parameters->port}"; $connection->expects($this->any()) diff --git a/tests/Predis/Connection/RedisClusterTest.php b/tests/Predis/Connection/Aggregate/RedisClusterTest.php similarity index 98% rename from tests/Predis/Connection/RedisClusterTest.php rename to tests/Predis/Connection/Aggregate/RedisClusterTest.php index 2e36d9b8..93af36cc 100644 --- a/tests/Predis/Connection/RedisClusterTest.php +++ b/tests/Predis/Connection/Aggregate/RedisClusterTest.php @@ -9,9 +9,10 @@ * file that was distributed with this source code. */ -namespace Predis\Connection; +namespace Predis\Connection\Aggregate; use PredisTestCase; +use Predis\Connection; use Predis\Profile; use Predis\Response; @@ -641,17 +642,17 @@ class RedisClusterTest extends PredisTestCase // ******************************************************************** // /** - * Returns a base mocked connection from Predis\Connection\SingleConnectionInterface. + * Returns a base mocked connection from Predis\Connection\NodeConnectionInterface. * * @param mixed $parameters Optional parameters. * @return mixed */ protected function getMockConnection($parameters = null) { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); if ($parameters) { - $parameters = Parameters::create($parameters); + $parameters = Connection\Parameters::create($parameters); $hash = "{$parameters->host}:{$parameters->port}"; $connection->expects($this->any()) diff --git a/tests/Predis/Connection/ComposableStreamConnectionTest.php b/tests/Predis/Connection/ComposableStreamConnectionTest.php index dea1426f..4c8f4786 100644 --- a/tests/Predis/Connection/ComposableStreamConnectionTest.php +++ b/tests/Predis/Connection/ComposableStreamConnectionTest.php @@ -14,14 +14,14 @@ namespace Predis\Connection; /** * */ -class ComposableStreamConnectionTest extends PredisConnectionTestCase +class CompositeStreamConnectionTest extends PredisConnectionTestCase { /** * @group disconnected */ public function testConstructorDoesNotOpenConnection() { - $connection = new ComposableStreamConnection($this->getParameters()); + $connection = new CompositeStreamConnection($this->getParameters()); $this->assertFalse($connection->isConnected()); } @@ -32,7 +32,7 @@ class ComposableStreamConnectionTest extends PredisConnectionTestCase public function testExposesParameters() { $parameters = $this->getParameters(); - $connection = new ComposableStreamConnection($parameters); + $connection = new CompositeStreamConnection($parameters); $this->assertSame($parameters, $connection->getParameters()); } @@ -45,7 +45,7 @@ class ComposableStreamConnectionTest extends PredisConnectionTestCase public function testThrowsExceptionOnInvalidScheme() { $parameters = $this->getParameters(array('scheme' => 'udp')); - $connection = new ComposableStreamConnection($parameters); + $connection = new CompositeStreamConnection($parameters); } /** @@ -54,7 +54,7 @@ class ComposableStreamConnectionTest extends PredisConnectionTestCase public function testCanBeSerialized() { $parameters = $this->getParameters(array('alias' => 'redis', 'read_write_timeout' => 10)); - $connection = new ComposableStreamConnection($parameters); + $connection = new CompositeStreamConnection($parameters); $unserialized = unserialize(serialize($connection)); @@ -108,7 +108,7 @@ class ComposableStreamConnectionTest extends PredisConnectionTestCase $parameters = $this->getParameters($parameters); $profile = $this->getProfile(); - $connection = new ComposableStreamConnection($parameters); + $connection = new CompositeStreamConnection($parameters); if ($initialize) { $connection->addConnectCommand( diff --git a/tests/Predis/Connection/ConnectionExceptionTest.php b/tests/Predis/Connection/ConnectionExceptionTest.php index 1a879ded..c259b0c2 100644 --- a/tests/Predis/Connection/ConnectionExceptionTest.php +++ b/tests/Predis/Connection/ConnectionExceptionTest.php @@ -23,7 +23,7 @@ class ConnectionExceptionTest extends CommunicationExceptionTest /** * {@inheritdoc} */ - protected function getException(SingleConnectionInterface $connection, $message, $code = 0, \Exception $inner = null) + protected function getException(NodeConnectionInterface $connection, $message, $code = 0, \Exception $inner = null) { return new ConnectionException($connection, $message, $code, $inner); } diff --git a/tests/Predis/Connection/FactoryTest.php b/tests/Predis/Connection/FactoryTest.php index 8e65f8c7..1ef644a7 100644 --- a/tests/Predis/Connection/FactoryTest.php +++ b/tests/Predis/Connection/FactoryTest.php @@ -68,7 +68,7 @@ class FactoryTest extends PredisTestCase $connection = $factory->create(null); $parameters = $connection->getParameters(); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); + $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection); $this->assertEquals('tcp', $parameters->scheme); $this->assertFalse(isset($parameters->custom)); @@ -84,7 +84,7 @@ class FactoryTest extends PredisTestCase $connection = $factory->create(array('scheme' => 'tcp', 'custom' => 'foobar')); $parameters = $connection->getParameters(); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); + $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection); $this->assertEquals('tcp', $parameters->scheme); $this->assertTrue(isset($parameters->custom)); @@ -100,7 +100,7 @@ class FactoryTest extends PredisTestCase $connection = $factory->create('tcp://127.0.0.1?custom=foobar'); $parameters = $connection->getParameters(); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); + $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection); $this->assertEquals('tcp', $parameters->scheme); $this->assertTrue(isset($parameters->custom)); @@ -119,7 +119,7 @@ class FactoryTest extends PredisTestCase $parameters = new Parameters(); $connection = $factory->create($parameters); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); + $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection); } /** @@ -133,7 +133,7 @@ class FactoryTest extends PredisTestCase 'password' => 'foobar' )); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->once()) ->method('getParameters') ->will($this->returnValue($parameters)); @@ -239,7 +239,7 @@ class FactoryTest extends PredisTestCase $factory->undefine('unknown'); $connection = $factory->create('tcp://127.0.0.1'); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); + $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection); } /** @@ -267,10 +267,10 @@ class FactoryTest extends PredisTestCase { list(, $connectionClass) = $this->getMockConnectionClass(); - $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface'); + $cluster = $this->getMock('Predis\Connection\Aggregate\ClusterInterface'); $cluster->expects($this->exactly(2)) ->method('add') - ->with($this->isInstanceOf('Predis\Connection\SingleConnectionInterface')); + ->with($this->isInstanceOf('Predis\Connection\NodeConnectionInterface')); $factory = $this->getMock('Predis\Connection\Factory', array('create')); $factory->expects($this->never()) @@ -286,10 +286,10 @@ class FactoryTest extends PredisTestCase { list(, $connectionClass) = $this->getMockConnectionClass(); - $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface'); + $cluster = $this->getMock('Predis\Connection\Aggregate\ClusterInterface'); $cluster->expects($this->exactly(4)) ->method('add') - ->with($this->isInstanceOf('Predis\Connection\SingleConnectionInterface')); + ->with($this->isInstanceOf('Predis\Connection\NodeConnectionInterface')); $factory = $this->getMock('Predis\Connection\Factory', array('create')); $factory->expects($this->exactly(3)) @@ -306,7 +306,7 @@ class FactoryTest extends PredisTestCase */ public function testAggregateConnectionWithEmptyListOfParameters() { - $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface'); + $cluster = $this->getMock('Predis\Connection\Aggregate\ClusterInterface'); $cluster->expects($this->never())->method('add'); $factory = $this->getMock('Predis\Connection\Factory', array('create')); @@ -321,13 +321,13 @@ class FactoryTest extends PredisTestCase // ******************************************************************** // /** - * Returns a mocked Predis\Connection\SingleConnectionInterface. + * Returns a mocked Predis\Connection\NodeConnectionInterface. * * @return array Mock instance and class name */ protected function getMockConnectionClass() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); return array($connection, get_class($connection)); } diff --git a/tests/Predis/Monitor/ConsumerTest.php b/tests/Predis/Monitor/ConsumerTest.php index f5d7282e..68c1242a 100644 --- a/tests/Predis/Monitor/ConsumerTest.php +++ b/tests/Predis/Monitor/ConsumerTest.php @@ -45,7 +45,7 @@ class ConsumerTest extends PredisTestCase */ public function testMonitorConsumerDoesNotWorkOnClusters() { - $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface'); + $cluster = $this->getMock('Predis\Connection\Aggregate\ClusterInterface'); $client = new Client($cluster); $monitor = new MonitorConsumer($client); @@ -58,7 +58,7 @@ class ConsumerTest extends PredisTestCase { $cmdMonitor = Profile\Factory::getDefault()->createCommand('monitor'); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $client = $this->getMock('Predis\Client', array('createCommand', 'executeCommand'), array($connection)); $client->expects($this->once()) @@ -80,7 +80,7 @@ class ConsumerTest extends PredisTestCase */ public function testStoppingConsumerClosesConnection() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $client = $this->getMock('Predis\Client', array('disconnect'), array($connection)); $client->expects($this->exactly(2))->method('disconnect'); @@ -94,7 +94,7 @@ class ConsumerTest extends PredisTestCase */ public function testGarbageCollectorRunStopsConsumer() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $client = $this->getMock('Predis\Client', array('disconnect'), array($connection)); $client->expects($this->once())->method('disconnect'); @@ -110,7 +110,7 @@ class ConsumerTest extends PredisTestCase { $message = '1323367530.939137 (db 15) "MONITOR"'; - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->once()) ->method('read') ->will($this->returnValue($message)); @@ -133,7 +133,7 @@ class ConsumerTest extends PredisTestCase { $message = '1323367530.939137 [15 127.0.0.1:37265] "MONITOR"'; - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->once()) ->method('read') ->will($this->returnValue($message)); diff --git a/tests/Predis/Pipeline/AtomicTest.php b/tests/Predis/Pipeline/AtomicTest.php index 9bedd3d6..8e32b40e 100644 --- a/tests/Predis/Pipeline/AtomicTest.php +++ b/tests/Predis/Pipeline/AtomicTest.php @@ -28,7 +28,7 @@ class AtomicTest extends PredisTestCase $pong = new Response\Status('PONG'); $queued = new Response\Status('QUEUED'); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->exactly(2)) ->method('executeCommand') ->will($this->onConsecutiveCalls(true, array($pong, $pong, $pong))); @@ -54,7 +54,7 @@ class AtomicTest extends PredisTestCase */ public function testThrowsExceptionOnAbortedTransaction() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->exactly(2)) ->method('executeCommand') ->will($this->onConsecutiveCalls(true, null)); @@ -78,7 +78,7 @@ class AtomicTest extends PredisTestCase $queued = new Response\Status('QUEUED'); $error = new Response\Error('ERR Test error'); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->at(0)) ->method('executeCommand') ->will($this->returnValue(true)); @@ -107,7 +107,7 @@ class AtomicTest extends PredisTestCase { $error = new Response\Error('ERR Test error'); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->once()) ->method('readResponse') ->will($this->returnValue($error)); @@ -129,7 +129,7 @@ class AtomicTest extends PredisTestCase $queued = new Response\Status('QUEUED'); $error = new Response\Error('ERR Test error'); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->exactly(3)) ->method('readResponse') ->will($this->onConsecutiveCalls($queued, $queued, $queued)); @@ -153,7 +153,7 @@ class AtomicTest extends PredisTestCase */ public function testExecutorWithAggregateConnection() { - $connection = $this->getMock('Predis\Connection\ClusterConnectionInterface'); + $connection = $this->getMock('Predis\Connection\Aggregate\ClusterInterface'); $pipeline = new Atomic(new Client($connection)); $pipeline->ping(); diff --git a/tests/Predis/Pipeline/FireAndForgetTest.php b/tests/Predis/Pipeline/FireAndForgetTest.php index b8e3222f..be2c3448 100644 --- a/tests/Predis/Pipeline/FireAndForgetTest.php +++ b/tests/Predis/Pipeline/FireAndForgetTest.php @@ -27,7 +27,7 @@ class FireAndForgetTest extends PredisTestCase { $profile = Profile\Factory::getDefault(); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->exactly(3))->method('writeRequest'); $connection->expects($this->never())->method('readResponse'); @@ -47,7 +47,7 @@ class FireAndForgetTest extends PredisTestCase { $profile = Profile\Factory::getDefault(); - $connection = $this->getMock('Predis\Connection\ReplicationConnectionInterface'); + $connection = $this->getMock('Predis\Connection\Aggregate\ReplicationInterface'); $connection->expects($this->once()) ->method('switchTo') ->with('master'); diff --git a/tests/Predis/Pipeline/PipelineTest.php b/tests/Predis/Pipeline/PipelineTest.php index 3e574a97..4a0ddfa4 100644 --- a/tests/Predis/Pipeline/PipelineTest.php +++ b/tests/Predis/Pipeline/PipelineTest.php @@ -40,7 +40,7 @@ class PipelineTest extends PredisTestCase */ public function testCallDoesNotSendCommandsWithoutExecute() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->never())->method('writeRequest'); $connection->expects($this->never())->method('readResponse'); @@ -56,7 +56,7 @@ class PipelineTest extends PredisTestCase */ public function testCallReturnsPipelineForFluentInterface() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->never())->method('writeRequest'); $connection->expects($this->never())->method('readResponse'); @@ -73,7 +73,7 @@ class PipelineTest extends PredisTestCase { $object = $this->getMock('Predis\Response\ResponseInterface'); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->once()) ->method('readResponse') ->will($this->returnValue($object)); @@ -94,7 +94,7 @@ class PipelineTest extends PredisTestCase { $error = new Response\Error('ERR Test error'); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->once()) ->method('readResponse') ->will($this->returnValue($error)); @@ -114,7 +114,7 @@ class PipelineTest extends PredisTestCase { $error = $this->getMock('Predis\Response\ErrorInterface'); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->exactly(2)) ->method('readResponse') ->will($this->returnValue($error)); @@ -135,7 +135,7 @@ class PipelineTest extends PredisTestCase public function testExecuteReturnsPipelineForFluentInterface() { $profile = Profile\Factory::getDefault(); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $pipeline = new Pipeline(new Client($connection)); $command = $profile->createCommand('echo', array('one')); @@ -149,7 +149,7 @@ class PipelineTest extends PredisTestCase { $profile = Profile\Factory::getDefault(); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->never())->method('writeRequest'); $connection->expects($this->never())->method('readResponse'); @@ -165,7 +165,7 @@ class PipelineTest extends PredisTestCase */ public function testExecuteWithEmptyBuffer() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->never())->method('writeRequest'); $connection->expects($this->never())->method('readResponse'); @@ -179,7 +179,7 @@ class PipelineTest extends PredisTestCase */ public function testExecuteWithFilledBuffer() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->exactly(3)) ->method('writeRequest'); $connection->expects($this->exactly(3)) @@ -218,7 +218,7 @@ class PipelineTest extends PredisTestCase */ public function testFlushHandlesPartialBuffers() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->exactly(4)) ->method('writeRequest'); $connection->expects($this->exactly(4)) @@ -243,7 +243,7 @@ class PipelineTest extends PredisTestCase { $pong = new Response\Status('PONG'); - $connection = $this->getMock('Predis\Connection\ReplicationConnectionInterface'); + $connection = $this->getMock('Predis\Connection\Aggregate\ReplicationInterface'); $connection->expects($this->once()) ->method('switchTo') ->with('master'); @@ -308,7 +308,7 @@ class PipelineTest extends PredisTestCase */ public function testExecuteWithCallableArgumentRunsPipelineInCallable() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->exactly(4)) ->method('writeRequest'); $connection->expects($this->exactly(4)) @@ -334,7 +334,7 @@ class PipelineTest extends PredisTestCase { $exception = null; - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->never())->method('writeRequest'); $connection->expects($this->never())->method('readResponse'); diff --git a/tests/Predis/Protocol/ProtocolExceptionTest.php b/tests/Predis/Protocol/ProtocolExceptionTest.php index a8b2ac7a..835a54ea 100644 --- a/tests/Predis/Protocol/ProtocolExceptionTest.php +++ b/tests/Predis/Protocol/ProtocolExceptionTest.php @@ -14,7 +14,7 @@ namespace Predis\Protocol; require_once __DIR__.'/../CommunicationExceptionTest.php'; use Predis\CommunicationExceptionTest; -use Predis\Connection\SingleConnectionInterface; +use Predis\Connection\NodeConnectionInterface; /** * @@ -24,7 +24,7 @@ class ProtocolExceptionTest extends CommunicationExceptionTest /** * {@inheritdoc} */ - protected function getException(SingleConnectionInterface $connection, $message, $code = 0, \Exception $inner = null) + protected function getException(NodeConnectionInterface $connection, $message, $code = 0, \Exception $inner = null) { return new ProtocolException($connection, $message, $code, $inner); } diff --git a/tests/Predis/Protocol/Text/ComposableProtocolProcessorTest.php b/tests/Predis/Protocol/Text/ComposableProtocolProcessorTest.php index 5f66f83d..269a87b0 100644 --- a/tests/Predis/Protocol/Text/ComposableProtocolProcessorTest.php +++ b/tests/Predis/Protocol/Text/ComposableProtocolProcessorTest.php @@ -81,7 +81,7 @@ class ComposableProtocolProcessorTest extends PredisTestCase $serialized = "*1\r\n$4\r\nPING\r\n"; $command = $this->getMock('Predis\Command\CommandInterface'); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $serializer = $this->getMock('Predis\Protocol\RequestSerializerInterface'); $protocol = new ComposableProtocolProcessor($serializer); @@ -105,7 +105,7 @@ class ComposableProtocolProcessorTest extends PredisTestCase { $serialized = "*1\r\n$4\r\nPING\r\n"; - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $reader = $this->getMock('Predis\Protocol\ResponseReaderInterface'); $protocol = new ComposableProtocolProcessor(null, $reader); diff --git a/tests/Predis/Protocol/Text/Handler/BulkResponseTest.php b/tests/Predis/Protocol/Text/Handler/BulkResponseTest.php index 4993acb5..24766cf4 100644 --- a/tests/Predis/Protocol/Text/Handler/BulkResponseTest.php +++ b/tests/Predis/Protocol/Text/Handler/BulkResponseTest.php @@ -25,7 +25,7 @@ class BulkResponseTest extends PredisTestCase { $handler = new Handler\BulkResponse(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->never())->method('readLine'); $connection->expects($this->once()) @@ -46,7 +46,7 @@ class BulkResponseTest extends PredisTestCase $handler = new Handler\BulkResponse(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->never())->method('readLine'); $connection->expects($this->once()) @@ -64,7 +64,7 @@ class BulkResponseTest extends PredisTestCase { $handler = new Handler\BulkResponse(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->never())->method('readLine'); $connection->expects($this->never())->method('readBuffer'); @@ -81,7 +81,7 @@ class BulkResponseTest extends PredisTestCase { $handler = new Handler\BulkResponse(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->never())->method('readLine'); $connection->expects($this->never())->method('readBuffer'); diff --git a/tests/Predis/Protocol/Text/Handler/ErrorResponseTest.php b/tests/Predis/Protocol/Text/Handler/ErrorResponseTest.php index f3bc5ee0..abf06ae8 100644 --- a/tests/Predis/Protocol/Text/Handler/ErrorResponseTest.php +++ b/tests/Predis/Protocol/Text/Handler/ErrorResponseTest.php @@ -25,7 +25,7 @@ class ErrorResponseTest extends PredisTestCase { $handler = new Handler\ErrorResponse(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->never())->method('readLine'); $connection->expects($this->never())->method('readBuffer'); diff --git a/tests/Predis/Protocol/Text/Handler/IntegerResponseTest.php b/tests/Predis/Protocol/Text/Handler/IntegerResponseTest.php index 6d19f174..4f1f5d6a 100644 --- a/tests/Predis/Protocol/Text/Handler/IntegerResponseTest.php +++ b/tests/Predis/Protocol/Text/Handler/IntegerResponseTest.php @@ -25,7 +25,7 @@ class IntegerResponseTest extends PredisTestCase { $handler = new Handler\IntegerResponse(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->never())->method('readLine'); $connection->expects($this->never())->method('readBuffer'); @@ -43,7 +43,7 @@ class IntegerResponseTest extends PredisTestCase { $handler = new Handler\IntegerResponse(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->never())->method('readLine'); $connection->expects($this->never())->method('readBuffer'); @@ -60,7 +60,7 @@ class IntegerResponseTest extends PredisTestCase { $handler = new Handler\IntegerResponse(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->never())->method('readLine'); $connection->expects($this->never())->method('readBuffer'); diff --git a/tests/Predis/Protocol/Text/Handler/MultiBulkResponseTest.php b/tests/Predis/Protocol/Text/Handler/MultiBulkResponseTest.php index bc8d4630..8d3a78bd 100644 --- a/tests/Predis/Protocol/Text/Handler/MultiBulkResponseTest.php +++ b/tests/Predis/Protocol/Text/Handler/MultiBulkResponseTest.php @@ -25,7 +25,7 @@ class MultiBulkResponseTest extends PredisTestCase { $handler = new Handler\MultiBulkResponse(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->once()) ->method('getProtocol') @@ -57,7 +57,7 @@ class MultiBulkResponseTest extends PredisTestCase { $handler = new Handler\MultiBulkResponse(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->never())->method('readLine'); $connection->expects($this->never())->method('readBuffer'); @@ -74,7 +74,7 @@ class MultiBulkResponseTest extends PredisTestCase { $handler = new Handler\MultiBulkResponse(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->never())->method('readLine'); $connection->expects($this->never())->method('readBuffer'); diff --git a/tests/Predis/Protocol/Text/Handler/StatusResponseTest.php b/tests/Predis/Protocol/Text/Handler/StatusResponseTest.php index ac732f98..185c393a 100644 --- a/tests/Predis/Protocol/Text/Handler/StatusResponseTest.php +++ b/tests/Predis/Protocol/Text/Handler/StatusResponseTest.php @@ -25,7 +25,7 @@ class StatusResponseTest extends PredisTestCase { $handler = new Handler\StatusResponse(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->never())->method('readLine'); $connection->expects($this->never())->method('readBuffer'); @@ -43,7 +43,7 @@ class StatusResponseTest extends PredisTestCase { $handler = new Handler\StatusResponse(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->never())->method('readLine'); $connection->expects($this->never())->method('readBuffer'); @@ -61,7 +61,7 @@ class StatusResponseTest extends PredisTestCase { $handler = new Handler\StatusResponse(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->never())->method('readLine'); $connection->expects($this->never())->method('readBuffer'); diff --git a/tests/Predis/Protocol/Text/Handler/StreamableMultiBulkResponseTest.php b/tests/Predis/Protocol/Text/Handler/StreamableMultiBulkResponseTest.php index edb7d149..62bb9fa7 100644 --- a/tests/Predis/Protocol/Text/Handler/StreamableMultiBulkResponseTest.php +++ b/tests/Predis/Protocol/Text/Handler/StreamableMultiBulkResponseTest.php @@ -25,7 +25,7 @@ class StreamableMultiBulkResponseTest extends PredisTestCase { $handler = new Handler\StreamableMultiBulkResponse(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->never())->method('readLine'); $connection->expects($this->never())->method('readBuffer'); @@ -42,7 +42,7 @@ class StreamableMultiBulkResponseTest extends PredisTestCase { $handler = new Handler\StreamableMultiBulkResponse(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->never())->method('readLine'); $connection->expects($this->never())->method('readBuffer'); diff --git a/tests/Predis/Protocol/Text/ProtocolProcessorTest.php b/tests/Predis/Protocol/Text/ProtocolProcessorTest.php index 457bc4ec..4c04e538 100644 --- a/tests/Predis/Protocol/Text/ProtocolProcessorTest.php +++ b/tests/Predis/Protocol/Text/ProtocolProcessorTest.php @@ -36,7 +36,7 @@ class ProtocolProcessorTest extends PredisTestCase ->method('getArguments') ->will($this->returnValue(array())); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->once()) ->method('writeBuffer') @@ -53,7 +53,7 @@ class ProtocolProcessorTest extends PredisTestCase { $protocol = new ProtocolProcessor(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->at(0)) ->method('readLine') @@ -90,7 +90,7 @@ class ProtocolProcessorTest extends PredisTestCase $protocol = new ProtocolProcessor(); $protocol->useIterableMultibulk(true); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->once(4)) ->method('readLine') @@ -108,7 +108,7 @@ class ProtocolProcessorTest extends PredisTestCase { $protocol = new ProtocolProcessor(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->once()) ->method('readLine') diff --git a/tests/Predis/Protocol/Text/ResponseReaderTest.php b/tests/Predis/Protocol/Text/ResponseReaderTest.php index 74d9b160..f6302924 100644 --- a/tests/Predis/Protocol/Text/ResponseReaderTest.php +++ b/tests/Predis/Protocol/Text/ResponseReaderTest.php @@ -57,7 +57,7 @@ class ResponseReaderTest extends PredisTestCase $protocol = new ComposableProtocolProcessor(); $protocol->setResponseReader($reader); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->at(0)) ->method('readLine') @@ -95,7 +95,7 @@ class ResponseReaderTest extends PredisTestCase { $reader = new ResponseReader(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->once()) ->method('readLine') @@ -112,7 +112,7 @@ class ResponseReaderTest extends PredisTestCase { $reader = new ResponseReader(); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $connection->expects($this->once()) ->method('readLine') diff --git a/tests/Predis/PubSub/ConsumerTest.php b/tests/Predis/PubSub/ConsumerTest.php index 4b88dd11..2e27666b 100644 --- a/tests/Predis/PubSub/ConsumerTest.php +++ b/tests/Predis/PubSub/ConsumerTest.php @@ -44,7 +44,7 @@ class ConsumerTest extends PredisTestCase */ public function testPubSubConsumerDoesNotWorkOnClusters() { - $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface'); + $cluster = $this->getMock('Predis\Connection\Aggregate\ClusterInterface'); $client = new Client($cluster); $pubsub = new PubSubConsumer($client); @@ -55,7 +55,7 @@ class ConsumerTest extends PredisTestCase */ public function testConstructorWithoutSubscriptionsDoesNotStartConsumer() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $client = $this->getMock('Predis\Client', array('executeCommand'), array($connection)); $client->expects($this->never())->method('executeCommand'); @@ -73,7 +73,7 @@ class ConsumerTest extends PredisTestCase $cmdSubscribe = $profile->createCommand('subscribe', array('channel:foo')); $cmdPsubscribe = $profile->createCommand('psubscribe', array('channels:*')); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->exactly(2))->method('writeRequest'); $client = $this->getMock('Predis\Client', array('createCommand', 'writeRequest'), array($connection)); @@ -93,7 +93,7 @@ class ConsumerTest extends PredisTestCase */ public function testStoppingConsumerWithTrueClosesConnection() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $client = $this->getMock('Predis\Client', array('disconnect'), array($connection)); $client->expects($this->exactly(1))->method('disconnect'); @@ -114,7 +114,7 @@ class ConsumerTest extends PredisTestCase $classUnsubscribe = $profile->getCommandClass('unsubscribe'); $classPunsubscribe = $profile->getCommandClass('punsubscribe'); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $client = $this->getMock('Predis\Client', array('disconnect'), array($connection)); @@ -136,7 +136,7 @@ class ConsumerTest extends PredisTestCase */ public function testIsNotValidWhenNotSubscribed() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $client = $this->getMock('Predis\Client', array('disconnect'), array($connection)); $pubsub = new PubSubConsumer($client); @@ -152,7 +152,7 @@ class ConsumerTest extends PredisTestCase { $rawmessage = array('message', 'channel:foo', 'message from channel'); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->once())->method('read')->will($this->returnValue($rawmessage)); $client = new Client($connection); @@ -171,7 +171,7 @@ class ConsumerTest extends PredisTestCase { $rawmessage = array('pmessage', 'channel:*', 'channel:foo', 'message from channel'); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->once())->method('read')->will($this->returnValue($rawmessage)); $client = new Client($connection); @@ -191,7 +191,7 @@ class ConsumerTest extends PredisTestCase { $rawmessage = array('subscribe', 'channel:foo', 1); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->once())->method('read')->will($this->returnValue($rawmessage)); $client = new Client($connection); @@ -210,7 +210,7 @@ class ConsumerTest extends PredisTestCase { $rawmessage = array('unsubscribe', 'channel:foo', 1); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->once())->method('read')->will($this->returnValue($rawmessage)); $client = new Client($connection); @@ -229,7 +229,7 @@ class ConsumerTest extends PredisTestCase { $rawmessage = array('unsubscribe', 'channel:foo', 0); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->once())->method('read')->will($this->returnValue($rawmessage)); $client = new Client($connection); @@ -250,7 +250,7 @@ class ConsumerTest extends PredisTestCase */ public function testGetUnderlyingClientInstance() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $client = new Client($connection); $pubsub = new PubSubConsumer($client); diff --git a/tests/Predis/Response/Iterator/MultiBulkTest.php b/tests/Predis/Response/Iterator/MultiBulkTest.php index 2f5ce5c5..91157089 100644 --- a/tests/Predis/Response/Iterator/MultiBulkTest.php +++ b/tests/Predis/Response/Iterator/MultiBulkTest.php @@ -13,7 +13,7 @@ namespace Predis\Response\Iterator; use PredisTestCase; use Predis\Client; -use Predis\Connection\ComposableStreamConnection; +use Predis\Connection\CompositeStreamConnection; use Predis\Protocol\Text\ProtocolProcessor as TextProtocolProcessor; /** @@ -123,7 +123,7 @@ class MultiBulkTest extends PredisTestCase $protocol = new TextProtocolProcessor(); $protocol->useIterableMultibulk(true); - $connection = new ComposableStreamConnection($parameters, $protocol); + $connection = new CompositeStreamConnection($parameters, $protocol); $client = new Client($connection); $client->connect(); diff --git a/tests/Predis/Response/Iterator/MultiBulkTupleTest.php b/tests/Predis/Response/Iterator/MultiBulkTupleTest.php index 6780bb22..a8a0a397 100644 --- a/tests/Predis/Response/Iterator/MultiBulkTupleTest.php +++ b/tests/Predis/Response/Iterator/MultiBulkTupleTest.php @@ -13,7 +13,7 @@ namespace Predis\Response\Iterator; use PredisTestCase; use Predis\Client; -use Predis\Connection\ComposableStreamConnection; +use Predis\Connection\CompositeStreamConnection; use Predis\Protocol\Text\ProtocolProcessor as TextProtocolProcessor; /** @@ -28,7 +28,7 @@ class MultiBulkTupleTest extends PredisTestCase */ public function testInitiatedMultiBulkIteratorsAreNotValid() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $iterator = new MultiBulk($connection, 2); $iterator->next(); @@ -42,7 +42,7 @@ class MultiBulkTupleTest extends PredisTestCase */ public function testMultiBulkWithOddSizesAreInvalid() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $iterator = new MultiBulk($connection, 3); new MultiBulkTuple($iterator); @@ -109,7 +109,7 @@ class MultiBulkTupleTest extends PredisTestCase $protocol = new TextProtocolProcessor(); $protocol->useIterableMultibulk(true); - $connection = new ComposableStreamConnection($parameters, $protocol); + $connection = new CompositeStreamConnection($parameters, $protocol); $client = new Client($connection); $client->connect(); diff --git a/tests/Predis/Transaction/MultiExecTest.php b/tests/Predis/Transaction/MultiExecTest.php index 1ee49ace..f12e1877 100644 --- a/tests/Predis/Transaction/MultiExecTest.php +++ b/tests/Predis/Transaction/MultiExecTest.php @@ -28,7 +28,7 @@ class MultiExecTest extends PredisTestCase */ public function testThrowsExceptionOnUnsupportedMultiExecInProfile() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $client = new Client($connection, array('profile' => '1.2')); $tx = new MultiExec($client); } @@ -40,7 +40,7 @@ class MultiExecTest extends PredisTestCase */ public function testThrowsExceptionOnUnsupportedWatchInProfile() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $client = new Client($connection, array('profile' => '2.0')); $tx = new MultiExec($client, array('options' => 'cas')); @@ -54,7 +54,7 @@ class MultiExecTest extends PredisTestCase */ public function testThrowsExceptionOnUnsupportedUnwatchInProfile() { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $client = new Client($connection, array('profile' => '2.0')); $tx = new MultiExec($client, array('options' => 'cas')); @@ -727,15 +727,15 @@ class MultiExecTest extends PredisTestCase // ******************************************************************** // /** - * Returns a mocked instance of Predis\Connection\SingleConnectionInterface + * Returns a mocked instance of Predis\Connection\NodeConnectionInterface * using the specified callback to return values from executeCommand(). * - * @param \Closure $executeCallback - * @return \Predis\Connection\SingleConnectionInterface + * @param \Closure $executeCallback + * @return \Predis\Connection\NodeConnectionInterface */ protected function getMockedConnection($executeCallback) { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->any()) ->method('executeCommand') ->will($this->returnCallback($executeCallback)); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index e55c9065..4ff9aca7 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -11,7 +11,7 @@ if (file_exists(__DIR__.'/../autoload.php')) { require __DIR__.'/../autoload.php'; -} else if (@include('Predis/Autoloader.php')) { +} elseif (@include('Predis/Autoloader.php')) { Predis\Autoloader::register(); } else { die('ERROR: Unable to find a suitable mean to register Predis\Autoloader.');