From b71c798f9b175b8dbd9523ae41d0d89270c07056 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Sat, 16 Nov 2013 13:02:35 +0100 Subject: [PATCH] Rename classes in Predis\Response and Predis\Response\Iterator. This change aims to make class names shorter with less redundant fully qualified names. Merge! --- lib/Predis/Client.php | 16 ++++++------ lib/Predis/Connection/PhpiredisConnection.php | 7 +++--- .../Connection/PhpiredisStreamConnection.php | 7 +++--- lib/Predis/Connection/RedisCluster.php | 8 +++--- lib/Predis/Connection/StreamConnection.php | 7 +++--- lib/Predis/Connection/WebdisConnection.php | 4 +-- lib/Predis/Pipeline/MultiExecExecutor.php | 10 +++----- lib/Predis/Pipeline/StandardExecutor.php | 21 ++++++++-------- .../Protocol/Text/Handler/ErrorResponse.php | 4 +-- .../Protocol/Text/Handler/StatusResponse.php | 4 +-- .../Handler/StreamableMultiBulkResponse.php | 4 +-- .../Protocol/Text/ProtocolProcessor.php | 11 ++++---- .../Response/{ResponseError.php => Error.php} | 2 +- ...eErrorInterface.php => ErrorInterface.php} | 2 +- ...tiBulkResponseSimple.php => MultiBulk.php} | 6 ++--- ...BulkResponse.php => MultiBulkIterator.php} | 4 +-- ...lkResponseTuple.php => MultiBulkTuple.php} | 10 ++++---- ...bjectInterface.php => ObjectInterface.php} | 2 +- lib/Predis/Response/ServerException.php | 10 ++++---- .../{ResponseQueued.php => StatusQueued.php} | 2 +- lib/Predis/Transaction/MultiExecContext.php | 12 ++++----- tests/PHPUnit/ConnectionTestCase.php | 4 +-- tests/Predis/ClientTest.php | 15 ++++++----- .../Predis/Command/TransactionDiscardTest.php | 2 +- tests/Predis/Command/TransactionMultiTest.php | 4 +-- .../Predis/Command/TransactionUnwatchTest.php | 2 +- tests/Predis/Command/TransactionWatchTest.php | 4 +-- .../ComposableStreamConnectionTest.php | 2 +- tests/Predis/Connection/RedisClusterTest.php | 10 ++++---- .../Predis/Pipeline/MultiExecExecutorTest.php | 14 +++++------ tests/Predis/Pipeline/PipelineContextTest.php | 2 +- .../Predis/Pipeline/StandardExecutorTest.php | 13 +++++----- .../Text/Handler/ErrorResponseTest.php | 2 +- .../Text/Handler/IntegerResponseTest.php | 1 - .../Text/Handler/StatusResponseTest.php | 3 +-- .../StreamableMultiBulkResponseTest.php | 2 +- .../Protocol/Text/ProtocolProcessorTest.php | 2 +- .../{ResponseErrorTest.php => ErrorTest.php} | 14 +++++------ ...sponseSimpleTest.php => MultiBulkTest.php} | 8 +++--- ...seTupleTest.php => MultiBulkTupleTest.php} | 14 +++++------ tests/Predis/Response/ServerExceptionTest.php | 10 ++++---- ...nseQueuedTest.php => StatusQueuedTest.php} | 10 ++++---- .../Transaction/MultiExecContextTest.php | 25 +++++++++---------- 43 files changed, 150 insertions(+), 166 deletions(-) rename lib/Predis/Response/{ResponseError.php => Error.php} (95%) rename lib/Predis/Response/{ResponseErrorInterface.php => ErrorInterface.php} (91%) rename lib/Predis/Response/Iterator/{MultiBulkResponseSimple.php => MultiBulk.php} (93%) rename lib/Predis/Response/Iterator/{MultiBulkResponse.php => MultiBulkIterator.php} (94%) rename lib/Predis/Response/Iterator/{MultiBulkResponseTuple.php => MultiBulkTuple.php} (82%) rename lib/Predis/Response/{ResponseObjectInterface.php => ObjectInterface.php} (91%) rename lib/Predis/Response/{ResponseQueued.php => StatusQueued.php} (95%) rename tests/Predis/Response/{ResponseErrorTest.php => ErrorTest.php} (68%) rename tests/Predis/Response/Iterator/{MultiBulkResponseSimpleTest.php => MultiBulkTest.php} (95%) rename tests/Predis/Response/Iterator/{MultiBulkResponseTupleTest.php => MultiBulkTupleTest.php} (91%) rename tests/Predis/Response/{ResponseQueuedTest.php => StatusQueuedTest.php} (75%) diff --git a/lib/Predis/Client.php b/lib/Predis/Client.php index cf2410df..b624ec43 100644 --- a/lib/Predis/Client.php +++ b/lib/Predis/Client.php @@ -24,9 +24,7 @@ use Predis\Monitor\MonitorContext; use Predis\Pipeline\PipelineContext; use Predis\Profile\ServerProfile; use Predis\PubSub\PubSubContext; -use Predis\Response\ResponseErrorInterface; -use Predis\Response\ResponseObjectInterface; -use Predis\Response\ServerException; +use Predis\Response; use Predis\Transaction\MultiExecContext; /** @@ -283,8 +281,8 @@ class Client implements ClientInterface { $response = $this->connection->executeCommand($command); - if ($response instanceof ResponseObjectInterface) { - if ($response instanceof ResponseErrorInterface) { + if ($response instanceof Response\ObjectInterface) { + if ($response instanceof Response\ErrorInterface) { $response = $this->onResponseError($command, $response); } @@ -298,10 +296,10 @@ class Client implements ClientInterface * Handles -ERR responses returned by Redis. * * @param CommandInterface $command Redis command that generated the error. - * @param ResponseErrorInterface $response Instance of the error response. + * @param Response\ErrorInterface $response Instance of the error response. * @return mixed */ - protected function onResponseError(CommandInterface $command, ResponseErrorInterface $response) + protected function onResponseError(CommandInterface $command, Response\ErrorInterface $response) { if ($command instanceof ScriptedCommand && $response->getErrorType() === 'NOSCRIPT') { $eval = $this->createCommand('eval'); @@ -309,7 +307,7 @@ class Client implements ClientInterface $response = $this->executeCommand($eval); - if (!$response instanceof ResponseObjectInterface) { + if (!$response instanceof Response\ObjectInterface) { $response = $command->parseResponse($response); } @@ -317,7 +315,7 @@ class Client implements ClientInterface } if ($this->options->exceptions) { - throw new ServerException($response->getMessage()); + throw new Response\ServerException($response->getMessage()); } return $response; diff --git a/lib/Predis/Connection/PhpiredisConnection.php b/lib/Predis/Connection/PhpiredisConnection.php index bd3fe010..e9d21ac1 100644 --- a/lib/Predis/Connection/PhpiredisConnection.php +++ b/lib/Predis/Connection/PhpiredisConnection.php @@ -13,8 +13,7 @@ namespace Predis\Connection; use Predis\NotSupportedException; use Predis\Command\CommandInterface; -use Predis\Response\ResponseError; -use Predis\Response\ResponseQueued; +use Predis\Response; /** * This class provides the implementation of a Predis connection that uses the @@ -122,7 +121,7 @@ class PhpiredisConnection extends AbstractConnection return true; case 'QUEUED': - return new ResponseQueued(); + return new Response\StatusQueued(); default: return $payload; @@ -139,7 +138,7 @@ class PhpiredisConnection extends AbstractConnection private function getErrorHandler() { return function ($errorMessage) { - return new ResponseError($errorMessage); + return new Response\Error($errorMessage); }; } diff --git a/lib/Predis/Connection/PhpiredisStreamConnection.php b/lib/Predis/Connection/PhpiredisStreamConnection.php index 6513fcef..a6eec890 100644 --- a/lib/Predis/Connection/PhpiredisStreamConnection.php +++ b/lib/Predis/Connection/PhpiredisStreamConnection.php @@ -13,8 +13,7 @@ namespace Predis\Connection; use Predis\NotSupportedException; use Predis\Command\CommandInterface; -use Predis\Response\ResponseError; -use Predis\Response\ResponseQueued; +use Predis\Response; /** * This class provides the implementation of a Predis connection that uses PHP's @@ -109,7 +108,7 @@ class PhpiredisStreamConnection extends StreamConnection return true; case 'QUEUED': - return new ResponseQueued(); + return new Response\StatusQueued(); default: return $payload; @@ -126,7 +125,7 @@ class PhpiredisStreamConnection extends StreamConnection protected function getErrorHandler() { return function ($errorMessage) { - return new ResponseError($errorMessage); + return new Response\Error($errorMessage); }; } diff --git a/lib/Predis/Connection/RedisCluster.php b/lib/Predis/Connection/RedisCluster.php index 7906652d..d81cc580 100644 --- a/lib/Predis/Connection/RedisCluster.php +++ b/lib/Predis/Connection/RedisCluster.php @@ -16,7 +16,7 @@ use Predis\Cluster\CommandHashStrategyInterface; use Predis\NotSupportedException; use Predis\Cluster\RedisClusterHashStrategy; use Predis\Command\CommandInterface; -use Predis\Response\ResponseErrorInterface; +use Predis\Response; /** * Abstraction for Redis cluster (Redis v3.0). @@ -334,10 +334,10 @@ class RedisCluster implements ClusterConnectionInterface, \IteratorAggregate, \C * Handles -ERR replies from Redis. * * @param CommandInterface $command Command that generated the -ERR reply. - * @param ResponseErrorInterface $error Redis error reply object. + * @param Response\ErrorInterface $error Redis error reply object. * @return mixed */ - protected function handleServerError(CommandInterface $command, ResponseErrorInterface $error) + protected function handleServerError(CommandInterface $command, Response\ErrorInterface $error) { list($type, $details) = explode(' ', $error->getMessage(), 2); @@ -375,7 +375,7 @@ class RedisCluster implements ClusterConnectionInterface, \IteratorAggregate, \C $connection = $this->getConnection($command); $reply = $connection->executeCommand($command); - if ($reply instanceof ResponseErrorInterface) { + if ($reply instanceof Response\ErrorInterface) { return $this->handleServerError($command, $reply); } diff --git a/lib/Predis/Connection/StreamConnection.php b/lib/Predis/Connection/StreamConnection.php index 09759cb2..1adb8761 100644 --- a/lib/Predis/Connection/StreamConnection.php +++ b/lib/Predis/Connection/StreamConnection.php @@ -12,8 +12,7 @@ namespace Predis\Connection; use Predis\Command\CommandInterface; -use Predis\Response\ResponseError; -use Predis\Response\ResponseQueued; +use Predis\Response; /** * Standard connection to Redis servers implemented on top of PHP's streams. @@ -190,7 +189,7 @@ class StreamConnection extends AbstractConnection return true; case 'QUEUED': - return new ResponseQueued(); + return new Response\StatusQueued(); default: return $payload; @@ -237,7 +236,7 @@ class StreamConnection extends AbstractConnection return (int) $payload; case '-': // error - return new ResponseError($payload); + return new Response\Error($payload); default: $this->onProtocolError("Unknown prefix: '$prefix'"); diff --git a/lib/Predis/Connection/WebdisConnection.php b/lib/Predis/Connection/WebdisConnection.php index 2f367cec..54ecf527 100644 --- a/lib/Predis/Connection/WebdisConnection.php +++ b/lib/Predis/Connection/WebdisConnection.php @@ -15,7 +15,7 @@ use Predis\NotSupportedException; use Predis\Command\CommandInterface; use Predis\Connection\ConnectionException; use Predis\Protocol\ProtocolException; -use Predis\Response\ResponseError; +use Predis\Response; /** * This class implements a Predis connection that actually talks with Webdis @@ -161,7 +161,7 @@ class WebdisConnection implements SingleConnectionInterface protected function getErrorHandler() { return function ($errorMessage) { - return new ResponseError($errorMessage); + return new Response\Error($errorMessage); }; } diff --git a/lib/Predis/Pipeline/MultiExecExecutor.php b/lib/Predis/Pipeline/MultiExecExecutor.php index 69f8750d..51765846 100644 --- a/lib/Predis/Pipeline/MultiExecExecutor.php +++ b/lib/Predis/Pipeline/MultiExecExecutor.php @@ -17,9 +17,7 @@ use Predis\Connection\ConnectionInterface; use Predis\Connection\SingleConnectionInterface; use Predis\Profile\ServerProfile; use Predis\Profile\ServerProfileInterface; -use Predis\Response\ResponseErrorInterface; -use Predis\Response\ResponseObjectInterface; -use Predis\Response\ServerException; +use Predis\Response; /** * Implements a pipeline executor that wraps the whole pipeline @@ -72,11 +70,11 @@ class MultiExecExecutor implements PipelineExecutorInterface foreach ($commands as $command) { $response = $connection->readResponse($command); - if ($response instanceof ResponseErrorInterface) { + if ($response instanceof Response\ErrorInterface) { $cmd = $this->profile->createCommand('discard'); $connection->executeCommand($cmd); - throw new ServerException($response->getMessage()); + throw new Response\ServerException($response->getMessage()); } } @@ -110,7 +108,7 @@ class MultiExecExecutor implements PipelineExecutorInterface $command = $commands->dequeue(); $response = $responses[$i]; - if ($response instanceof ResponseObjectInterface) { + if ($response instanceof Response\ObjectInterface) { $values[$i] = $response; } else { $values[$i] = $command->parseResponse($response); diff --git a/lib/Predis/Pipeline/StandardExecutor.php b/lib/Predis/Pipeline/StandardExecutor.php index 99643def..58f617b4 100644 --- a/lib/Predis/Pipeline/StandardExecutor.php +++ b/lib/Predis/Pipeline/StandardExecutor.php @@ -15,9 +15,7 @@ use SplQueue; use Predis\Command\CommandInterface; use Predis\Connection\ConnectionInterface; use Predis\Connection\ReplicationConnectionInterface; -use Predis\Response\ResponseErrorInterface; -use Predis\Response\ResponseObjectInterface; -use Predis\Response\ServerException; +use Predis\Response; /** * Implements the standard pipeline executor strategy used @@ -57,12 +55,15 @@ class StandardExecutor implements PipelineExecutorInterface * * @param ConnectionInterface $connection * @param CommandInterface $command - * @param ResponseObjectInterface $response + * @param Response\ObjectInterface $response * @return mixed */ - protected function onResponseObject(ConnectionInterface $connection, CommandInterface $command, ResponseObjectInterface $response) + protected function onResponseObject( + ConnectionInterface $connection, + CommandInterface $command, + Response\ObjectInterface $response) { - if ($response instanceof ResponseErrorInterface) { + if ($response instanceof Response\ErrorInterface) { return $this->onResponseError($connection, $response); } @@ -73,9 +74,9 @@ class StandardExecutor implements PipelineExecutorInterface * Handles -ERR responses returned by Redis. * * @param ConnectionInterface $connection The connection that returned the error. - * @param ResponseErrorInterface $response The error response instance. + * @param Response\ErrorInterface $response The error response instance. */ - protected function onResponseError(ConnectionInterface $connection, ResponseErrorInterface $response) + protected function onResponseError(ConnectionInterface $connection, Response\ErrorInterface $response) { if (!$this->exceptions) { return $response; @@ -85,7 +86,7 @@ class StandardExecutor implements PipelineExecutorInterface $connection->disconnect(); $message = $response->getMessage(); - throw new ServerException($message); + throw new Response\ServerException($message); } /** @@ -105,7 +106,7 @@ class StandardExecutor implements PipelineExecutorInterface $command = $commands->dequeue(); $response = $connection->readResponse($command); - if ($response instanceof ResponseObjectInterface) { + if ($response instanceof Response\ObjectInterface) { $values[] = $this->onResponseObject($connection, $command, $response); } else { $values[] = $command->parseResponse($response); diff --git a/lib/Predis/Protocol/Text/Handler/ErrorResponse.php b/lib/Predis/Protocol/Text/Handler/ErrorResponse.php index 0785445e..6458ee5e 100644 --- a/lib/Predis/Protocol/Text/Handler/ErrorResponse.php +++ b/lib/Predis/Protocol/Text/Handler/ErrorResponse.php @@ -12,7 +12,7 @@ namespace Predis\Protocol\Text\Handler; use Predis\Connection\ComposableConnectionInterface; -use Predis\Response\ResponseError; +use Predis\Response; /** * Handler for the error response type in the standard Redis wire protocol. @@ -28,6 +28,6 @@ class ErrorResponse implements ResponseHandlerInterface */ public function handle(ComposableConnectionInterface $connection, $payload) { - return new ResponseError($payload); + return new Response\Error($payload); } } diff --git a/lib/Predis/Protocol/Text/Handler/StatusResponse.php b/lib/Predis/Protocol/Text/Handler/StatusResponse.php index 1d7cb4c9..8b526cb8 100644 --- a/lib/Predis/Protocol/Text/Handler/StatusResponse.php +++ b/lib/Predis/Protocol/Text/Handler/StatusResponse.php @@ -12,7 +12,7 @@ namespace Predis\Protocol\Text\Handler; use Predis\Connection\ComposableConnectionInterface; -use Predis\Response\ResponseQueued; +use Predis\Response; /** * Handler for the status response type in the standard Redis wire protocol. @@ -34,7 +34,7 @@ class StatusResponse implements ResponseHandlerInterface return true; case 'QUEUED': - return new ResponseQueued(); + return new Response\StatusQueued(); default: return $status; diff --git a/lib/Predis/Protocol/Text/Handler/StreamableMultiBulkResponse.php b/lib/Predis/Protocol/Text/Handler/StreamableMultiBulkResponse.php index 7ffebdb2..6e7eb764 100644 --- a/lib/Predis/Protocol/Text/Handler/StreamableMultiBulkResponse.php +++ b/lib/Predis/Protocol/Text/Handler/StreamableMultiBulkResponse.php @@ -13,7 +13,7 @@ namespace Predis\Protocol\Text\Handler; use Predis\CommunicationException; use Predis\Connection\ComposableConnectionInterface; -use Predis\Response\Iterator\MultiBulkResponseSimple; +use Predis\Response\Iterator\MultiBulk; use Predis\Protocol\ProtocolException; /** @@ -42,6 +42,6 @@ class StreamableMultiBulkResponse implements ResponseHandlerInterface )); } - return new MultiBulkResponseSimple($connection, $length); + return new MultiBulk($connection, $length); } } diff --git a/lib/Predis/Protocol/Text/ProtocolProcessor.php b/lib/Predis/Protocol/Text/ProtocolProcessor.php index 265f547d..3e4c5f55 100644 --- a/lib/Predis/Protocol/Text/ProtocolProcessor.php +++ b/lib/Predis/Protocol/Text/ProtocolProcessor.php @@ -16,9 +16,8 @@ use Predis\Command\CommandInterface; use Predis\Connection\ComposableConnectionInterface; use Predis\Protocol\ProtocolException; use Predis\Protocol\ProtocolProcessorInterface; -use Predis\Response\ResponseError; -use Predis\Response\ResponseQueued; -use Predis\Response\Iterator\MultiBulkResponseSimple; +use Predis\Response; +use Predis\Response\Iterator; /** * Protocol processor for the standard Redis wire protocol. @@ -65,7 +64,7 @@ class ProtocolProcessor implements ProtocolProcessorInterface return true; case 'QUEUED': - return new ResponseQueued(); + return new Response\StatusQueued(); default: return $payload; @@ -85,7 +84,7 @@ class ProtocolProcessor implements ProtocolProcessorInterface return null; } if ($this->mbiterable) { - return new MultiBulkResponseSimple($connection, $count); + return new Iterator\MultiBulk($connection, $count); } $multibulk = array(); @@ -100,7 +99,7 @@ class ProtocolProcessor implements ProtocolProcessorInterface return (int) $payload; case '-': // error - return new ResponseError($payload); + return new Response\Error($payload); default: CommunicationException::handle(new ProtocolException( diff --git a/lib/Predis/Response/ResponseError.php b/lib/Predis/Response/Error.php similarity index 95% rename from lib/Predis/Response/ResponseError.php rename to lib/Predis/Response/Error.php index d7f41d37..a58f8f70 100644 --- a/lib/Predis/Response/ResponseError.php +++ b/lib/Predis/Response/Error.php @@ -17,7 +17,7 @@ namespace Predis\Response; * * @author Daniele Alessandri */ -class ResponseError implements ResponseErrorInterface +class Error implements ErrorInterface { private $message; diff --git a/lib/Predis/Response/ResponseErrorInterface.php b/lib/Predis/Response/ErrorInterface.php similarity index 91% rename from lib/Predis/Response/ResponseErrorInterface.php rename to lib/Predis/Response/ErrorInterface.php index 24dcc35b..a5ecf4c8 100644 --- a/lib/Predis/Response/ResponseErrorInterface.php +++ b/lib/Predis/Response/ErrorInterface.php @@ -17,7 +17,7 @@ namespace Predis\Response; * * @author Daniele Alessandri */ -interface ResponseErrorInterface extends ResponseObjectInterface +interface ErrorInterface extends ObjectInterface { /** * Returns the error message diff --git a/lib/Predis/Response/Iterator/MultiBulkResponseSimple.php b/lib/Predis/Response/Iterator/MultiBulk.php similarity index 93% rename from lib/Predis/Response/Iterator/MultiBulkResponseSimple.php rename to lib/Predis/Response/Iterator/MultiBulk.php index 97507ba5..ccc47e9b 100644 --- a/lib/Predis/Response/Iterator/MultiBulkResponseSimple.php +++ b/lib/Predis/Response/Iterator/MultiBulk.php @@ -18,7 +18,7 @@ use Predis\Connection\SingleConnectionInterface; * * @author Daniele Alessandri */ -class MultiBulkResponseSimple extends MultiBulkResponse +class MultiBulk extends MultiBulkIterator { private $connection; @@ -79,10 +79,10 @@ class MultiBulkResponseSimple extends MultiBulkResponse * Returns an iterator that reads the multi-bulk response as * list of tuples. * - * @return MultiBulkResponseTuple + * @return MultiBulkTuple */ public function asTuple() { - return new MultiBulkResponseTuple($this); + return new MultiBulkTuple($this); } } diff --git a/lib/Predis/Response/Iterator/MultiBulkResponse.php b/lib/Predis/Response/Iterator/MultiBulkIterator.php similarity index 94% rename from lib/Predis/Response/Iterator/MultiBulkResponse.php rename to lib/Predis/Response/Iterator/MultiBulkIterator.php index 822ea404..bafc3c4a 100644 --- a/lib/Predis/Response/Iterator/MultiBulkResponse.php +++ b/lib/Predis/Response/Iterator/MultiBulkIterator.php @@ -13,7 +13,7 @@ namespace Predis\Response\Iterator; use Iterator; use Countable; -use Predis\Response\ResponseObjectInterface; +use Predis\Response; /** * Iterator that abstracts the access to multibulk responses allowing them to be @@ -27,7 +27,7 @@ use Predis\Response\ResponseObjectInterface; * * @author Daniele Alessandri */ -abstract class MultiBulkResponse implements Iterator, Countable, ResponseObjectInterface +abstract class MultiBulkIterator implements Iterator, Countable, Response\ObjectInterface { protected $current; protected $position; diff --git a/lib/Predis/Response/Iterator/MultiBulkResponseTuple.php b/lib/Predis/Response/Iterator/MultiBulkTuple.php similarity index 82% rename from lib/Predis/Response/Iterator/MultiBulkResponseTuple.php rename to lib/Predis/Response/Iterator/MultiBulkTuple.php index fd126e64..7f31a12f 100644 --- a/lib/Predis/Response/Iterator/MultiBulkResponseTuple.php +++ b/lib/Predis/Response/Iterator/MultiBulkTuple.php @@ -24,14 +24,14 @@ use UnexpectedValueException; * * @author Daniele Alessandri */ -class MultiBulkResponseTuple extends MultiBulkResponse implements OuterIterator +class MultiBulkTuple extends MultiBulk implements OuterIterator { private $iterator; /** - * @param MultiBulkResponseSimple $iterator Inner multibulk response iterator. + * @param MultiBulk $iterator Inner multibulk response iterator. */ - public function __construct(MultiBulkResponseSimple $iterator) + public function __construct(MultiBulk $iterator) { $this->checkPreconditions($iterator); @@ -44,9 +44,9 @@ class MultiBulkResponseTuple extends MultiBulkResponse implements OuterIterator /** * Checks for valid preconditions. * - * @param MultiBulkResponseSimple $iterator Inner multibulk response iterator. + * @param MultiBulk $iterator Inner multibulk response iterator. */ - protected function checkPreconditions(MultiBulkResponseSimple $iterator) + protected function checkPreconditions(MultiBulk $iterator) { if ($iterator->getPosition() !== 0) { throw new RuntimeException('Cannot initialize a tuple iterator with an already initiated iterator'); diff --git a/lib/Predis/Response/ResponseObjectInterface.php b/lib/Predis/Response/ObjectInterface.php similarity index 91% rename from lib/Predis/Response/ResponseObjectInterface.php rename to lib/Predis/Response/ObjectInterface.php index 238ba88a..8a01107e 100644 --- a/lib/Predis/Response/ResponseObjectInterface.php +++ b/lib/Predis/Response/ObjectInterface.php @@ -16,6 +16,6 @@ namespace Predis\Response; * * @author Daniele Alessandri */ -interface ResponseObjectInterface +interface ObjectInterface { } diff --git a/lib/Predis/Response/ServerException.php b/lib/Predis/Response/ServerException.php index 1eb5bb7c..31c24266 100644 --- a/lib/Predis/Response/ServerException.php +++ b/lib/Predis/Response/ServerException.php @@ -18,7 +18,7 @@ use Predis\PredisException; * * @author Daniele Alessandri */ -class ServerException extends PredisException implements ResponseErrorInterface +class ServerException extends PredisException implements ErrorInterface { /** * Gets the type of the error returned by Redis. @@ -33,12 +33,12 @@ class ServerException extends PredisException implements ResponseErrorInterface } /** - * Converts the exception to an instance of ResponseError. + * Converts the exception to an instance of Predis\Response\Error. * - * @return ResponseError + * @return Error */ - public function toResponseError() + public function toErrorResponse() { - return new ResponseError($this->getMessage()); + return new Error($this->getMessage()); } } diff --git a/lib/Predis/Response/ResponseQueued.php b/lib/Predis/Response/StatusQueued.php similarity index 95% rename from lib/Predis/Response/ResponseQueued.php rename to lib/Predis/Response/StatusQueued.php index f32120bb..f0fdf205 100644 --- a/lib/Predis/Response/ResponseQueued.php +++ b/lib/Predis/Response/StatusQueued.php @@ -17,7 +17,7 @@ namespace Predis\Response; * * @author Daniele Alessandri */ -class ResponseQueued implements ResponseObjectInterface +class StatusQueued implements ObjectInterface { /** * Converts the object to its string representation. diff --git a/lib/Predis/Transaction/MultiExecContext.php b/lib/Predis/Transaction/MultiExecContext.php index 6ed1c010..e2dc2f2f 100644 --- a/lib/Predis/Transaction/MultiExecContext.php +++ b/lib/Predis/Transaction/MultiExecContext.php @@ -18,9 +18,7 @@ use Predis\ClientInterface; use Predis\CommunicationException; use Predis\ExecutableContextInterface; use Predis\NotSupportedException; -use Predis\Response\ResponseErrorInterface; -use Predis\Response\ResponseQueued; -use Predis\Response\ServerException; +use Predis\Response; use Predis\Command\CommandInterface; use Predis\Connection\AggregatedConnectionInterface; use Predis\Protocol\ProtocolException; @@ -212,7 +210,7 @@ class MultiExecContext implements BasicClientInterface, ExecutableContextInterfa return $response; } - if (!$response instanceof ResponseQueued) { + if (!$response instanceof Response\StatusQueued) { $this->onProtocolError('The server did not respond with a QUEUED status reply'); } @@ -388,9 +386,9 @@ class MultiExecContext implements BasicClientInterface, ExecutableContextInterfa for ($i = 0; $i < $size; $i++) { $commandReply = $reply[$i]; - if ($commandReply instanceof ResponseErrorInterface && $useExceptions) { + if ($commandReply instanceof Response\ErrorInterface && $useExceptions) { $message = $commandReply->getMessage(); - throw new ServerException($message); + throw new Response\ServerException($message); } $values[$i] = $commands->dequeue()->parseResponse($commandReply); @@ -413,7 +411,7 @@ class MultiExecContext implements BasicClientInterface, ExecutableContextInterfa call_user_func($callable, $this); } catch (CommunicationException $exception) { $blockException = $exception; - } catch (ServerException $exception) { + } catch (Response\ServerException $exception) { $blockException = $exception; } catch (\Exception $exception) { $blockException = $exception; diff --git a/tests/PHPUnit/ConnectionTestCase.php b/tests/PHPUnit/ConnectionTestCase.php index 0bcb6e36..fb17aaad 100644 --- a/tests/PHPUnit/ConnectionTestCase.php +++ b/tests/PHPUnit/ConnectionTestCase.php @@ -219,7 +219,7 @@ abstract class ConnectionTestCase extends StandardTestCase $connection->writeCommand($profile->createCommand('multi')); $connection->writeCommand($profile->createCommand('ping')); $this->assertTrue($connection->read()); - $this->assertInstanceOf('Predis\Response\ResponseQueued', $connection->read()); + $this->assertInstanceOf('Predis\Response\StatusQueued', $connection->read()); } /** @@ -261,7 +261,7 @@ abstract class ConnectionTestCase extends StandardTestCase $connection->executeCommand($profile->createCommand('set', array('foo', 'bar'))); $connection->writeCommand($profile->createCommand('rpush', array('foo', 'baz'))); - $this->assertInstanceOf('Predis\Response\ResponseError', $error = $connection->read()); + $this->assertInstanceOf('Predis\Response\Error', $error = $connection->read()); $this->assertRegExp('/[ERR|WRONGTYPE] Operation against a key holding the wrong kind of value/', $error->getMessage()); } diff --git a/tests/Predis/ClientTest.php b/tests/Predis/ClientTest.php index 6f2dd5ee..cdabcca6 100644 --- a/tests/Predis/ClientTest.php +++ b/tests/Predis/ClientTest.php @@ -17,8 +17,7 @@ use Predis\Connection\ConnectionFactory; use Predis\Connection\MasterSlaveReplication; use Predis\Connection\PredisCluster; use Predis\Profile\ServerProfile; -use Predis\Response\ResponseError; -use Predis\Response\ResponseQueued; +use Predis\Response; /** * @@ -406,7 +405,7 @@ class ClientTest extends StandardTestCase public function testExecuteCommandThrowsExceptionOnRedisError() { $ping = ServerProfile::getDefault()->createCommand('ping', array()); - $expectedResponse = new ResponseError('ERR Operation against a key holding the wrong kind of value'); + $expectedResponse = new Response\Error('ERR Operation against a key holding the wrong kind of value'); $connection= $this->getMock('Predis\Connection\ConnectionInterface'); $connection->expects($this->once()) @@ -423,7 +422,7 @@ class ClientTest extends StandardTestCase public function testExecuteCommandReturnsErrorResponseOnRedisError() { $ping = ServerProfile::getDefault()->createCommand('ping', array()); - $expectedResponse = new ResponseError('ERR Operation against a key holding the wrong kind of value'); + $expectedResponse = new Response\Error('ERR Operation against a key holding the wrong kind of value'); $connection= $this->getMock('Predis\Connection\ConnectionInterface'); $connection->expects($this->once()) @@ -468,7 +467,7 @@ class ClientTest extends StandardTestCase */ public function testCallingRedisCommandThrowsExceptionOnServerError() { - $expectedResponse = new ResponseError('ERR Operation against a key holding the wrong kind of value'); + $expectedResponse = new Response\Error('ERR Operation against a key holding the wrong kind of value'); $connection = $this->getMock('Predis\Connection\ConnectionInterface'); $connection->expects($this->once()) @@ -485,7 +484,7 @@ class ClientTest extends StandardTestCase */ public function testCallingRedisCommandReturnsErrorResponseOnRedisError() { - $expectedResponse = new ResponseError('ERR Operation against a key holding the wrong kind of value'); + $expectedResponse = new Response\Error('ERR Operation against a key holding the wrong kind of value'); $connection = $this->getMock('Predis\Connection\ConnectionInterface'); $connection->expects($this->once()) @@ -725,7 +724,7 @@ class ClientTest extends StandardTestCase $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); $connection->expects($this->once()) ->method('executeCommand') - ->will($this->returnValue(new ResponseQueued())); + ->will($this->returnValue(new Response\StatusQueued())); $txCallback = function ($tx) { $tx->ping(); @@ -769,7 +768,7 @@ class ClientTest extends StandardTestCase $connection->expects($this->at(0)) ->method('executeCommand') ->with($command) - ->will($this->returnValue(new ResponseError('NOSCRIPT'))); + ->will($this->returnValue(new Response\Error('NOSCRIPT'))); $connection->expects($this->at(1)) ->method('executeCommand') ->with($this->isInstanceOf('Predis\Command\ServerEval')) diff --git a/tests/Predis/Command/TransactionDiscardTest.php b/tests/Predis/Command/TransactionDiscardTest.php index 256c5a17..9d3d0794 100644 --- a/tests/Predis/Command/TransactionDiscardTest.php +++ b/tests/Predis/Command/TransactionDiscardTest.php @@ -63,7 +63,7 @@ class TransactionDiscardTest extends CommandTestCase $redis->multi(); - $this->assertInstanceOf('Predis\Response\ResponseQueued', $redis->set('foo', 'bar')); + $this->assertInstanceOf('Predis\Response\StatusQueued', $redis->set('foo', 'bar')); $this->assertTrue($redis->discard()); $this->assertFalse($redis->exists('foo')); } diff --git a/tests/Predis/Command/TransactionMultiTest.php b/tests/Predis/Command/TransactionMultiTest.php index 7a4007cf..d3350a04 100644 --- a/tests/Predis/Command/TransactionMultiTest.php +++ b/tests/Predis/Command/TransactionMultiTest.php @@ -74,8 +74,8 @@ class TransactionMultiTest extends CommandTestCase $redis = $this->getClient(); $this->assertTrue($redis->multi()); - $this->assertInstanceOf('Predis\Response\ResponseObjectInterface', $redis->echo('tx1')); - $this->assertInstanceOf('Predis\Response\ResponseQueued', $redis->echo('tx2')); + $this->assertInstanceOf('Predis\Response\ObjectInterface', $redis->echo('tx1')); + $this->assertInstanceOf('Predis\Response\StatusQueued', $redis->echo('tx2')); } /** diff --git a/tests/Predis/Command/TransactionUnwatchTest.php b/tests/Predis/Command/TransactionUnwatchTest.php index 7f986242..fc9cf7af 100644 --- a/tests/Predis/Command/TransactionUnwatchTest.php +++ b/tests/Predis/Command/TransactionUnwatchTest.php @@ -81,6 +81,6 @@ class TransactionUnwatchTest extends CommandTestCase $redis = $this->getClient(); $redis->multi(); - $this->assertInstanceOf('Predis\Response\ResponseQueued', $redis->unwatch()); + $this->assertInstanceOf('Predis\Response\StatusQueued', $redis->unwatch()); } } diff --git a/tests/Predis/Command/TransactionWatchTest.php b/tests/Predis/Command/TransactionWatchTest.php index a3f45d50..7f71f91c 100644 --- a/tests/Predis/Command/TransactionWatchTest.php +++ b/tests/Predis/Command/TransactionWatchTest.php @@ -108,7 +108,7 @@ class TransactionWatchTest extends CommandTestCase $this->assertTrue($redis1->watch('foo', 'hoge')); $this->assertTrue($redis1->multi()); - $this->assertInstanceOf('Predis\Response\ResponseQueued', $redis1->get('foo')); + $this->assertInstanceOf('Predis\Response\StatusQueued', $redis1->get('foo')); $this->assertTrue($redis2->set('foo', 'hijacked')); $this->assertNull($redis1->exec()); $this->assertSame('hijacked', $redis1->get('foo')); @@ -124,7 +124,7 @@ class TransactionWatchTest extends CommandTestCase $this->assertTrue($redis1->watch('foo')); $this->assertTrue($redis1->multi()); - $this->assertInstanceOf('Predis\Response\ResponseQueued', $redis1->set('foo', 'bar')); + $this->assertInstanceOf('Predis\Response\StatusQueued', $redis1->set('foo', 'bar')); $this->assertTrue($redis2->set('foo', 'hijacked')); $this->assertNull($redis1->exec()); $this->assertSame('hijacked', $redis1->get('foo')); diff --git a/tests/Predis/Connection/ComposableStreamConnectionTest.php b/tests/Predis/Connection/ComposableStreamConnectionTest.php index bbf597cf..25967aa9 100644 --- a/tests/Predis/Connection/ComposableStreamConnectionTest.php +++ b/tests/Predis/Connection/ComposableStreamConnectionTest.php @@ -80,7 +80,7 @@ class ComposableStreamConnectionTest extends ConnectionTestCase $connection->executeCommand($profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol'))); $connection->writeCommand($profile->createCommand('lrange', array('metavars', 0, -1))); - $this->assertInstanceOf('Predis\Response\Iterator\MultiBulkResponse', $iterator = $connection->read()); + $this->assertInstanceOf('Predis\Response\Iterator\MultiBulkIterator', $iterator = $connection->read()); $this->assertSame(array('foo', 'hoge', 'lol'), iterator_to_array($iterator)); } diff --git a/tests/Predis/Connection/RedisClusterTest.php b/tests/Predis/Connection/RedisClusterTest.php index 63c46745..d97f3c6b 100644 --- a/tests/Predis/Connection/RedisClusterTest.php +++ b/tests/Predis/Connection/RedisClusterTest.php @@ -14,7 +14,7 @@ namespace Predis\Connection; use \PHPUnit_Framework_TestCase as StandardTestCase; use Predis\Profile\ServerProfile; -use Predis\Response\ResponseError; +use Predis\Response; /** * @@ -423,7 +423,7 @@ class RedisClusterTest extends StandardTestCase */ public function testAskResponseWithConnectionInPool() { - $askResponse = new ResponseError('ASK 1970 127.0.0.1:6380'); + $askResponse = new Response\Error('ASK 1970 127.0.0.1:6380'); $command = ServerProfile::getDefault()->createCommand('get', array('node:1001')); @@ -456,7 +456,7 @@ class RedisClusterTest extends StandardTestCase */ public function testAskResponseWithConnectionNotInPool() { - $askResponse = new ResponseError('ASK 1970 127.0.0.1:6381'); + $askResponse = new Response\Error('ASK 1970 127.0.0.1:6381'); $command = ServerProfile::getDefault()->createCommand('get', array('node:1001')); @@ -496,7 +496,7 @@ class RedisClusterTest extends StandardTestCase */ public function testMovedResponseWithConnectionInPool() { - $movedResponse = new ResponseError('MOVED 1970 127.0.0.1:6380'); + $movedResponse = new Response\Error('MOVED 1970 127.0.0.1:6380'); $command = ServerProfile::getDefault()->createCommand('get', array('node:1001')); @@ -530,7 +530,7 @@ class RedisClusterTest extends StandardTestCase */ public function testMovedResponseWithConnectionNotInPool() { - $movedResponse = new ResponseError('MOVED 1970 127.0.0.1:6381'); + $movedResponse = new Response\Error('MOVED 1970 127.0.0.1:6381'); $command = ServerProfile::getDefault()->createCommand('get', array('node:1001')); diff --git a/tests/Predis/Pipeline/MultiExecExecutorTest.php b/tests/Predis/Pipeline/MultiExecExecutorTest.php index f8624885..aa8d7af6 100644 --- a/tests/Predis/Pipeline/MultiExecExecutorTest.php +++ b/tests/Predis/Pipeline/MultiExecExecutorTest.php @@ -15,9 +15,7 @@ use \PHPUnit_Framework_TestCase as StandardTestCase; use SplQueue; use Predis\Profile\ServerProfile; -use Predis\Response\ResponseError; -use Predis\Response\ResponseObjectInterface; -use Predis\Response\ResponseQueued; +use Predis\Response; /** * @@ -31,7 +29,7 @@ class MultiExecExecutorTest extends StandardTestCase { $executor = new MultiExecExecutor(); $pipeline = $this->getCommandsQueue(); - $queued = new ResponseQueued(); + $queued = new Response\StatusQueued(); $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); $connection->expects($this->exactly(2)) @@ -76,8 +74,8 @@ class MultiExecExecutorTest extends StandardTestCase { $executor = new MultiExecExecutor(); $pipeline = $this->getCommandsQueue(); - $queued = new ResponseQueued(); - $error = new ResponseError('ERR Test error'); + $queued = new Response\StatusQueued(); + $error = new Response\Error('ERR Test error'); $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); $connection->expects($this->at(0)) @@ -100,8 +98,8 @@ class MultiExecExecutorTest extends StandardTestCase { $executor = new MultiExecExecutor(); $pipeline = $this->getCommandsQueue(); - $queued = new ResponseQueued(); - $error = new ResponseError('ERR Test error'); + $queued = new Response\StatusQueued(); + $error = new Response\Error('ERR Test error'); $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); $connection->expects($this->exactly(3)) diff --git a/tests/Predis/Pipeline/PipelineContextTest.php b/tests/Predis/Pipeline/PipelineContextTest.php index 0b0169de..350096d0 100644 --- a/tests/Predis/Pipeline/PipelineContextTest.php +++ b/tests/Predis/Pipeline/PipelineContextTest.php @@ -377,7 +377,7 @@ class PipelineContextTest extends StandardTestCase }); $this->assertTrue($results[0]); - $this->assertInstanceOf('Predis\Response\ResponseError', $results[1]); + $this->assertInstanceOf('Predis\Response\Error', $results[1]); $this->assertSame('bar', $results[2]); } diff --git a/tests/Predis/Pipeline/StandardExecutorTest.php b/tests/Predis/Pipeline/StandardExecutorTest.php index 47b2fab2..b4919374 100644 --- a/tests/Predis/Pipeline/StandardExecutorTest.php +++ b/tests/Predis/Pipeline/StandardExecutorTest.php @@ -15,8 +15,7 @@ use \PHPUnit_Framework_TestCase as StandardTestCase; use SplQueue; use Predis\Profile\ServerProfile; -use Predis\Response\ResponseError; -use Predis\Response\ResponseObjectInterface; +use Predis\Response; /** * @@ -74,7 +73,7 @@ class StandardExecutorTest extends StandardTestCase public function testExecutorDoesNotParseResponseObjects() { $executor = new StandardExecutor(); - $response = $this->getMock('Predis\Response\ResponseObjectInterface'); + $response = $this->getMock('Predis\Response\ObjectInterface'); $this->simpleResponseObjectTest($executor, $response); } @@ -85,7 +84,7 @@ class StandardExecutorTest extends StandardTestCase public function testExecutorCanReturnRedisErrors() { $executor = new StandardExecutor(false); - $response = $this->getMock('Predis\Response\ResponseErrorInterface'); + $response = $this->getMock('Predis\Response\ErrorInterface'); $this->simpleResponseObjectTest($executor, $response); } @@ -99,7 +98,7 @@ class StandardExecutorTest extends StandardTestCase { $executor = new StandardExecutor(true); $pipeline = $this->getCommandsQueue(); - $error = new ResponseError('ERR Test error'); + $error = new Response\Error('ERR Test error'); $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); $connection->expects($this->once()) @@ -114,12 +113,12 @@ class StandardExecutorTest extends StandardTestCase // ******************************************************************** // /** - * Executes a test for the Predis\Response\ResponseObjectInterface type. + * Executes a test for the Predis\Response\ObjectInterface type. * * @param PipelineExecutorInterface $executor * @param ResponseObjectInterface $response */ - protected function simpleResponseObjectTest(PipelineExecutorInterface $executor, ResponseObjectInterface $response) + protected function simpleResponseObjectTest(PipelineExecutorInterface $executor, Response\ObjectInterface $response) { $pipeline = new SplQueue(); diff --git a/tests/Predis/Protocol/Text/Handler/ErrorResponseTest.php b/tests/Predis/Protocol/Text/Handler/ErrorResponseTest.php index 589a649a..dd2cb765 100644 --- a/tests/Predis/Protocol/Text/Handler/ErrorResponseTest.php +++ b/tests/Predis/Protocol/Text/Handler/ErrorResponseTest.php @@ -33,7 +33,7 @@ class ErrorResponseTest extends StandardTestCase $message = "ERR Operation against a key holding the wrong kind of value"; $response = $handler->handle($connection, $message); - $this->assertInstanceOf('Predis\Response\ResponseError', $response); + $this->assertInstanceOf('Predis\Response\Error', $response); $this->assertSame($message, $response->getMessage()); } } diff --git a/tests/Predis/Protocol/Text/Handler/IntegerResponseTest.php b/tests/Predis/Protocol/Text/Handler/IntegerResponseTest.php index e937eed7..6c271bb1 100644 --- a/tests/Predis/Protocol/Text/Handler/IntegerResponseTest.php +++ b/tests/Predis/Protocol/Text/Handler/IntegerResponseTest.php @@ -12,7 +12,6 @@ namespace Predis\Protocol\Text; use \PHPUnit_Framework_TestCase as StandardTestCase; -use Predis\Response\ResponseQueued; /** * diff --git a/tests/Predis/Protocol/Text/Handler/StatusResponseTest.php b/tests/Predis/Protocol/Text/Handler/StatusResponseTest.php index c276cf4c..15498a73 100644 --- a/tests/Predis/Protocol/Text/Handler/StatusResponseTest.php +++ b/tests/Predis/Protocol/Text/Handler/StatusResponseTest.php @@ -12,7 +12,6 @@ namespace Predis\Protocol\Text; use \PHPUnit_Framework_TestCase as StandardTestCase; -use Predis\Response\ResponseQueued; /** * @@ -46,7 +45,7 @@ class StatusResponseTest extends StandardTestCase $connection->expects($this->never())->method('readLine'); $connection->expects($this->never())->method('readBytes'); - $this->assertInstanceOf('Predis\Response\ResponseQueued', $handler->handle($connection, 'QUEUED')); + $this->assertInstanceOf('Predis\Response\StatusQueued', $handler->handle($connection, 'QUEUED')); } /** diff --git a/tests/Predis/Protocol/Text/Handler/StreamableMultiBulkResponseTest.php b/tests/Predis/Protocol/Text/Handler/StreamableMultiBulkResponseTest.php index 9caaa5bc..3f36cafb 100644 --- a/tests/Predis/Protocol/Text/Handler/StreamableMultiBulkResponseTest.php +++ b/tests/Predis/Protocol/Text/Handler/StreamableMultiBulkResponseTest.php @@ -30,7 +30,7 @@ class StreamableMultiBulkResponseTest extends StandardTestCase $connection->expects($this->never())->method('readLine'); $connection->expects($this->never())->method('readBytes'); - $this->assertInstanceOf('Predis\Response\Iterator\MultiBulkResponseSimple', $handler->handle($connection, '1')); + $this->assertInstanceOf('Predis\Response\Iterator\MultiBulk', $handler->handle($connection, '1')); } /** diff --git a/tests/Predis/Protocol/Text/ProtocolProcessorTest.php b/tests/Predis/Protocol/Text/ProtocolProcessorTest.php index 4cb5b836..7881434a 100644 --- a/tests/Predis/Protocol/Text/ProtocolProcessorTest.php +++ b/tests/Predis/Protocol/Text/ProtocolProcessorTest.php @@ -97,7 +97,7 @@ class ProtocolProcessorTest extends StandardTestCase ->method('readLine') ->will($this->returnValue("*1")); - $this->assertInstanceOf('Predis\Response\Iterator\MultiBulkResponseSimple', $protocol->read($connection)); + $this->assertInstanceOf('Predis\Response\Iterator\MultiBulk', $protocol->read($connection)); } /** diff --git a/tests/Predis/Response/ResponseErrorTest.php b/tests/Predis/Response/ErrorTest.php similarity index 68% rename from tests/Predis/Response/ResponseErrorTest.php rename to tests/Predis/Response/ErrorTest.php index ee3217ae..eac7113c 100644 --- a/tests/Predis/Response/ResponseErrorTest.php +++ b/tests/Predis/Response/ErrorTest.php @@ -16,7 +16,7 @@ use \PHPUnit_Framework_TestCase as StandardTestCase; /** * */ -class ResponseErrorTest extends StandardTestCase +class ErrorTest extends StandardTestCase { const ERR_WRONG_KEY_TYPE = 'ERR Operation against a key holding the wrong kind of value'; @@ -25,10 +25,10 @@ class ResponseErrorTest extends StandardTestCase */ public function testResponseErrorClass() { - $error = new ResponseError(self::ERR_WRONG_KEY_TYPE); + $error = new Error(self::ERR_WRONG_KEY_TYPE); - $this->assertInstanceOf('Predis\Response\ResponseErrorInterface', $error); - $this->assertInstanceOf('Predis\Response\ResponseObjectInterface', $error); + $this->assertInstanceOf('Predis\Response\ErrorInterface', $error); + $this->assertInstanceOf('Predis\Response\ObjectInterface', $error); } /** @@ -36,7 +36,7 @@ class ResponseErrorTest extends StandardTestCase */ public function testErrorMessage() { - $error = new ResponseError(self::ERR_WRONG_KEY_TYPE); + $error = new Error(self::ERR_WRONG_KEY_TYPE); $this->assertEquals(self::ERR_WRONG_KEY_TYPE, $error->getMessage()); } @@ -46,7 +46,7 @@ class ResponseErrorTest extends StandardTestCase */ public function testErrorType() { - $exception = new ResponseError(self::ERR_WRONG_KEY_TYPE); + $exception = new Error(self::ERR_WRONG_KEY_TYPE); $this->assertEquals('ERR', $exception->getErrorType()); } @@ -56,7 +56,7 @@ class ResponseErrorTest extends StandardTestCase */ public function testToString() { - $error = new ResponseError(self::ERR_WRONG_KEY_TYPE); + $error = new Error(self::ERR_WRONG_KEY_TYPE); $this->assertEquals(self::ERR_WRONG_KEY_TYPE, (string) $error); } diff --git a/tests/Predis/Response/Iterator/MultiBulkResponseSimpleTest.php b/tests/Predis/Response/Iterator/MultiBulkTest.php similarity index 95% rename from tests/Predis/Response/Iterator/MultiBulkResponseSimpleTest.php rename to tests/Predis/Response/Iterator/MultiBulkTest.php index fdda7817..f7986dc7 100644 --- a/tests/Predis/Response/Iterator/MultiBulkResponseSimpleTest.php +++ b/tests/Predis/Response/Iterator/MultiBulkTest.php @@ -21,7 +21,7 @@ use Predis\Protocol\Text\ProtocolProcessor as TextProtocolProcessor; /** * @group realm-iterators */ -class MultiBulkResponseSimpleTest extends StandardTestCase +class MultiBulkTest extends StandardTestCase { /** * @group connected @@ -32,7 +32,7 @@ class MultiBulkResponseSimpleTest extends StandardTestCase $client->rpush('metavars', 'foo', 'hoge', 'lol'); $this->assertInstanceOf('Iterator', $iterator = $client->lrange('metavars', 0, -1)); - $this->assertInstanceOf('Predis\Response\Iterator\MultiBulkResponseSimple', $iterator); + $this->assertInstanceOf('Predis\Response\Iterator\MultiBulk', $iterator); $this->assertTrue($iterator->valid()); $this->assertSame(3, $iterator->count()); @@ -59,8 +59,8 @@ class MultiBulkResponseSimpleTest extends StandardTestCase $client = $this->getClient(); $client->mset('foo', 'bar', 'hoge', 'piyo'); - $this->assertInstanceOf('Predis\Response\Iterator\MultiBulkResponseSimple', $iterator = $client->mget('foo', 'bar')); - $this->assertInstanceOf('Predis\Response\Iterator\MultiBulkResponseTuple', $iterator->asTuple()); + $this->assertInstanceOf('Predis\Response\Iterator\MultiBulk', $iterator = $client->mget('foo', 'bar')); + $this->assertInstanceOf('Predis\Response\Iterator\MultiBulkTuple', $iterator->asTuple()); } /** diff --git a/tests/Predis/Response/Iterator/MultiBulkResponseTupleTest.php b/tests/Predis/Response/Iterator/MultiBulkTupleTest.php similarity index 91% rename from tests/Predis/Response/Iterator/MultiBulkResponseTupleTest.php rename to tests/Predis/Response/Iterator/MultiBulkTupleTest.php index edda26be..2b4a62a3 100644 --- a/tests/Predis/Response/Iterator/MultiBulkResponseTupleTest.php +++ b/tests/Predis/Response/Iterator/MultiBulkTupleTest.php @@ -21,7 +21,7 @@ use Predis\Protocol\Text\ProtocolProcessor as TextProtocolProcessor; /** * @group realm-iterators */ -class MultiBulkResponseTupleTest extends StandardTestCase +class MultiBulkTupleTest extends StandardTestCase { /** * @group disconnected @@ -31,10 +31,10 @@ class MultiBulkResponseTupleTest extends StandardTestCase public function testInitiatedMultiBulkIteratorsAreNotValid() { $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $iterator = new MultiBulkResponseSimple($connection, 2); + $iterator = new MultiBulk($connection, 2); $iterator->next(); - new MultiBulkResponseTuple($iterator); + new MultiBulkTuple($iterator); } /** @@ -45,9 +45,9 @@ class MultiBulkResponseTupleTest extends StandardTestCase public function testMultiBulkWithOddSizesAreInvalid() { $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $iterator = new MultiBulkResponseSimple($connection, 3); + $iterator = new MultiBulk($connection, 3); - new MultiBulkResponseTuple($iterator); + new MultiBulkTuple($iterator); } /** @@ -59,8 +59,8 @@ class MultiBulkResponseTupleTest extends StandardTestCase $client->zadd('metavars', 1, 'foo', 2, 'hoge', 3, 'lol'); $this->assertInstanceOf('OuterIterator', $iterator = $client->zrange('metavars', 0, -1, 'withscores')->asTuple()); - $this->assertInstanceOf('Predis\Response\Iterator\MultiBulkResponseTuple', $iterator); - $this->assertInstanceOf('Predis\Response\Iterator\MultiBulkResponseSimple', $iterator->getInnerIterator()); + $this->assertInstanceOf('Predis\Response\Iterator\MultiBulkTuple', $iterator); + $this->assertInstanceOf('Predis\Response\Iterator\MultiBulk', $iterator->getInnerIterator()); $this->assertTrue($iterator->valid()); $this->assertSame(3, $iterator->count()); diff --git a/tests/Predis/Response/ServerExceptionTest.php b/tests/Predis/Response/ServerExceptionTest.php index 4dfa7508..1545f6bc 100644 --- a/tests/Predis/Response/ServerExceptionTest.php +++ b/tests/Predis/Response/ServerExceptionTest.php @@ -38,8 +38,8 @@ class ServerExceptionTest extends StandardTestCase $exception = new ServerException(self::ERR_WRONG_KEY_TYPE); $this->assertInstanceOf('Predis\Response\ServerException', $exception); - $this->assertInstanceOf('Predis\Response\ResponseErrorInterface', $exception); - $this->assertInstanceOf('Predis\Response\ResponseObjectInterface', $exception); + $this->assertInstanceOf('Predis\Response\ErrorInterface', $exception); + $this->assertInstanceOf('Predis\Response\ObjectInterface', $exception); $this->assertInstanceOf('Predis\PredisException', $exception); } @@ -56,12 +56,12 @@ class ServerExceptionTest extends StandardTestCase /** * @group disconnected */ - public function testToResponseError() + public function testToErrorResponse() { $exception = new ServerException(self::ERR_WRONG_KEY_TYPE); - $error = $exception->toResponseError(); + $error = $exception->toErrorResponse(); - $this->assertInstanceOf('Predis\Response\ResponseError', $error); + $this->assertInstanceOf('Predis\Response\Error', $error); $this->assertEquals($exception->getMessage(), $error->getMessage()); $this->assertEquals($exception->getErrorType(), $error->getErrorType()); diff --git a/tests/Predis/Response/ResponseQueuedTest.php b/tests/Predis/Response/StatusQueuedTest.php similarity index 75% rename from tests/Predis/Response/ResponseQueuedTest.php rename to tests/Predis/Response/StatusQueuedTest.php index 09bf06fd..212d9b13 100644 --- a/tests/Predis/Response/ResponseQueuedTest.php +++ b/tests/Predis/Response/StatusQueuedTest.php @@ -16,16 +16,16 @@ use \PHPUnit_Framework_TestCase as StandardTestCase; /** * */ -class ResponseQueuedTest extends StandardTestCase +class StatusQueuedTest extends StandardTestCase { /** * @group disconnected */ public function testResponseQueuedClass() { - $queued = new ResponseQueued(); + $queued = new StatusQueued(); - $this->assertInstanceOf('Predis\Response\ResponseObjectInterface', $queued); + $this->assertInstanceOf('Predis\Response\ObjectInterface', $queued); } /** @@ -33,7 +33,7 @@ class ResponseQueuedTest extends StandardTestCase */ public function testToString() { - $queued = new ResponseQueued(); + $queued = new StatusQueued(); $this->assertEquals('QUEUED', (string) $queued); } @@ -43,7 +43,7 @@ class ResponseQueuedTest extends StandardTestCase */ public function testQueuedProperty() { - $queued = new ResponseQueued(); + $queued = new StatusQueued(); $this->assertTrue(isset($queued->queued)); $this->assertTrue($queued->queued); diff --git a/tests/Predis/Transaction/MultiExecContextTest.php b/tests/Predis/Transaction/MultiExecContextTest.php index 212d5231..7b68358c 100644 --- a/tests/Predis/Transaction/MultiExecContextTest.php +++ b/tests/Predis/Transaction/MultiExecContextTest.php @@ -15,8 +15,7 @@ use \PHPUnit_Framework_TestCase as StandardTestCase; use Predis\Client; use Predis\Command\CommandInterface; -use Predis\Response\ResponseQueued; -use Predis\Response\ServerException; +use Predis\Response; /** * @group realm-transaction @@ -462,7 +461,7 @@ class MultiExecContextTest extends StandardTestCase $tx->echo('ERR Invalid operation'); $tx->get('foo'); }); - } catch (ServerException $ex) { + } catch (Response\ServerException $ex) { $tx->discard(); } @@ -510,11 +509,11 @@ class MultiExecContextTest extends StandardTestCase $tx->lpush('foo', 'bar'); $tx->set('foo', $value); }); - } catch (ServerException $ex) { + } catch (Response\ServerException $ex) { $exception = $ex; } - $this->assertInstanceOf('Predis\Response\ResponseErrorInterface', $exception); + $this->assertInstanceOf('Predis\Response\ErrorInterface', $exception); $this->assertSame($value, $client->get('foo')); } @@ -532,7 +531,7 @@ class MultiExecContextTest extends StandardTestCase }); $this->assertTrue($replies[0]); - $this->assertInstanceOf('Predis\Response\ResponseErrorInterface', $replies[1]); + $this->assertInstanceOf('Predis\Response\ErrorInterface', $replies[1]); $this->assertSame('foobar', $replies[2]); } @@ -685,21 +684,21 @@ class MultiExecContextTest extends StandardTestCase switch ($cmd) { case 'WATCH': if ($multi) { - throw new ServerException("ERR $cmd inside MULTI is not allowed"); + throw new Response\ServerException("ERR $cmd inside MULTI is not allowed"); } return $watch = true; case 'MULTI': if ($multi) { - throw new ServerException("ERR MULTI calls can not be nested"); + throw new Response\ServerException("ERR MULTI calls can not be nested"); } return $multi = true; case 'EXEC': if (!$multi) { - throw new ServerException("ERR $cmd without MULTI"); + throw new Response\ServerException("ERR $cmd without MULTI"); } $watch = $multi = false; @@ -714,7 +713,7 @@ class MultiExecContextTest extends StandardTestCase case 'DISCARD': if (!$multi) { - throw new ServerException("ERR $cmd without MULTI"); + throw new Response\ServerException("ERR $cmd without MULTI"); } $watch = $multi = false; @@ -724,20 +723,20 @@ class MultiExecContextTest extends StandardTestCase case 'ECHO': @list($trigger) = $command->getArguments(); if (strpos($trigger, 'ERR ') === 0) { - throw new ServerException($trigger); + throw new Response\ServerException($trigger); } if ($trigger === '!!ABORT!!' && $multi) { $abort = true; } - return new ResponseQueued(); + return new Response\StatusQueued(); case 'UNWATCH': $watch = false; default: - return $multi ? new ResponseQueued() : 'DUMMY_REPLY'; + return $multi ? new Response\StatusQueued() : 'DUMMY_REPLY'; } }; }