From 2a5483df90011fc8bbf68214a8dfe46955c24668 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Fri, 22 Nov 2013 12:01:29 +0100 Subject: [PATCH] Reorganize the Predis\Profile namespace. The profile factory code has been extrapolated into a the new class Predis\Profile\Factory (final and with only static methods). --- CHANGELOG.md | 3 + README.md | 21 +- examples/MasterSlaveReplicationComplex.php | 1 - lib/Predis/Client.php | 1 - lib/Predis/ClientInterface.php | 7 +- lib/Predis/Configuration/ProfileOption.php | 13 +- lib/Predis/Connection/ConnectionFactory.php | 13 +- lib/Predis/Pipeline/Atomic.php | 6 +- lib/Predis/Profile/Factory.php | 97 ++++++++ ...fileInterface.php => ProfileInterface.php} | 22 +- lib/Predis/Profile/RedisProfile.php | 146 +++++++++++ ...erverVersionNext.php => RedisUnstable.php} | 2 +- ...erverVersion12.php => RedisVersion120.php} | 2 +- ...erverVersion20.php => RedisVersion200.php} | 2 +- ...erverVersion22.php => RedisVersion220.php} | 2 +- ...erverVersion24.php => RedisVersion240.php} | 2 +- ...erverVersion26.php => RedisVersion260.php} | 2 +- ...erverVersion28.php => RedisVersion280.php} | 2 +- lib/Predis/Profile/ServerProfile.php | 228 ------------------ tests/PHPUnit/CommandTestCase.php | 7 +- tests/PHPUnit/ConnectionTestCase.php | 8 +- .../RedisProfileTestCase.php} | 130 +++++----- tests/PHPUnit/ServerVersionTestCase.php | 77 ------ tests/Predis/ClientTest.php | 24 +- tests/Predis/Cluster/PredisStrategyTest.php | 22 +- tests/Predis/Cluster/RedisStrategyTest.php | 24 +- .../Collection/Iterator/HashKeyTest.php | 30 +-- .../Collection/Iterator/KeyspaceTest.php | 30 +-- .../Collection/Iterator/ListKeyTest.php | 18 +- .../Predis/Collection/Iterator/SetKeyTest.php | 30 +-- .../Collection/Iterator/SortedSetKeyTest.php | 30 +-- tests/Predis/Configuration/OptionsTest.php | 8 +- .../Configuration/ProfileOptionTest.php | 30 +-- .../ComposableStreamConnectionTest.php | 2 - .../Connection/ConnectionFactoryTest.php | 8 +- .../Connection/MasterSlaveReplicationTest.php | 36 +-- .../Connection/PhpiredisConnectionTest.php | 2 - .../PhpiredisStreamConnectionTest.php | 2 - tests/Predis/Connection/PredisClusterTest.php | 14 +- tests/Predis/Connection/RedisClusterTest.php | 20 +- .../Connection/StreamConnectionTest.php | 2 - .../Connection/WebdisConnectionTest.php | 6 +- tests/Predis/Monitor/ConsumerTest.php | 6 +- tests/Predis/Pipeline/FireAndForgetTest.php | 6 +- tests/Predis/Pipeline/PipelineTest.php | 4 +- tests/Predis/Profile/FactoryTest.php | 97 ++++++++ ...sionNextTest.php => RedisUnstableTest.php} | 4 +- ...sion12Test.php => RedisVersion120Test.php} | 4 +- ...sion20Test.php => RedisVersion200Test.php} | 4 +- ...sion22Test.php => RedisVersion220Test.php} | 4 +- ...sion24Test.php => RedisVersion240Test.php} | 4 +- ...sion26Test.php => RedisVersion260Test.php} | 4 +- ...sion28Test.php => RedisVersion280Test.php} | 4 +- tests/Predis/PubSub/ConsumerTest.php | 8 +- tests/Predis/PubSub/DispatcherLoopTest.php | 1 - .../Replication/ReplicationStrategyTest.php | 16 +- tests/bootstrap.php | 2 +- 57 files changed, 653 insertions(+), 647 deletions(-) create mode 100644 lib/Predis/Profile/Factory.php rename lib/Predis/Profile/{ServerProfileInterface.php => ProfileInterface.php} (57%) create mode 100644 lib/Predis/Profile/RedisProfile.php rename lib/Predis/Profile/{ServerVersionNext.php => RedisUnstable.php} (93%) rename lib/Predis/Profile/{ServerVersion12.php => RedisVersion120.php} (99%) rename lib/Predis/Profile/{ServerVersion20.php => RedisVersion200.php} (99%) rename lib/Predis/Profile/{ServerVersion22.php => RedisVersion220.php} (99%) rename lib/Predis/Profile/{ServerVersion24.php => RedisVersion240.php} (99%) rename lib/Predis/Profile/{ServerVersion26.php => RedisVersion260.php} (99%) rename lib/Predis/Profile/{ServerVersion28.php => RedisVersion280.php} (99%) delete mode 100644 lib/Predis/Profile/ServerProfile.php rename tests/{Predis/Profile/ServerProfileTest.php => PHPUnit/RedisProfileTestCase.php} (67%) delete mode 100644 tests/PHPUnit/ServerVersionTestCase.php create mode 100644 tests/Predis/Profile/FactoryTest.php rename tests/Predis/Profile/{ServerVersionNextTest.php => RedisUnstableTest.php} (97%) rename tests/Predis/Profile/{ServerVersion12Test.php => RedisVersion120Test.php} (96%) rename tests/Predis/Profile/{ServerVersion20Test.php => RedisVersion200Test.php} (97%) rename tests/Predis/Profile/{ServerVersion22Test.php => RedisVersion220Test.php} (97%) rename tests/Predis/Profile/{ServerVersion24Test.php => RedisVersion240Test.php} (97%) rename tests/Predis/Profile/{ServerVersion26Test.php => RedisVersion260Test.php} (97%) rename tests/Predis/Profile/{ServerVersion28Test.php => RedisVersion280Test.php} (98%) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb4e4b08..1218f1b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,9 @@ v0.9.0 (201x-xx-xx) have been moved in the new `Predis\Response` namespace and most of them have been renamed to make their fully-qualified name shorter and less redundant. +- The profile factory code has been extrapolated from the abstract Redis profile + class and it's now in `Predis\Profile\Factory`. + v0.8.5 (2013-xx-xx) =============================================================================== diff --git a/README.md b/README.md index 264be5d8..9cab9b69 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ More details are available on the [official wiki](http://wiki.github.com/nrk/pre ## Main features ## -- Wide range of Redis versions supported (from __1.2__ to __2.8__ and unstable) using server profiles. +- Wide range of Redis versions supported (from __1.2__ to __2.8__ and unstable) using profiles. - Smart support for [redis-cluster](http://redis.io/topics/cluster-spec) (Redis >= 3.0). - Client-side sharding via consistent hashing or custom distribution strategies. - Support for master / slave replication configurations (write on master, read from slaves). @@ -28,7 +28,7 @@ More details are available on the [official wiki](http://wiki.github.com/nrk/pre - Connections to Redis instances are lazily established upon the first call to a command by the client. - Ability to connect to Redis using TCP/IP or UNIX domain sockets with support for persistent connections. - Ability to specify alternative connection classes to use different types of network or protocol backends. -- Flexible system to define and register your own set of commands or server profiles to client instances. +- Flexible system to define and register your own set of commands or profiles to client instances. ## How to use Predis ## @@ -178,11 +178,10 @@ $redis->newcmd(); ### Abstraction for handling Lua scripts as plain Redis commands ### A scripted command in Predis is an abstraction for [Lua scripting](http://redis.io/commands/eval) -with Redis >= 2.6 that allows to use a Lua script as if it was a plain Redis command registered -in the server profile being used by the client instance. Internally, scripted commands use -[EVALSHA](http://redis.io/commands/evalsha) to refer to a Lua script by its SHA1 hash in order -to save bandwidth, but they are capable of falling back to [EVAL](http://redis.io/commands/eval) -when needed: +in Redis >= 2.6 allowing to use a Lua script as if it was a Redis command registered in the profile +used by the client. Internally scripted commands use [EVALSHA](http://redis.io/commands/evalsha) to +refer to a Lua script by its SHA1 hash in order to save bandwidth, but they are capable of falling +back to [EVAL](http://redis.io/commands/eval) when needed: ```php class ListPushRandomValue extends Predis\Command\ScriptedCommand @@ -220,10 +219,10 @@ Predis has a comprehensive test suite covering every aspect of the library. The tests against a running instance of Redis (>= 2.4.0 is required) to verify the correct behaviour of the implementation of each command and automatically skips commands not defined in the selected version of Redis. If you do not have Redis up and running, integration tests can be disabled. By default, the test -suite is configured to execute integration tests using the server profile for Redis v2.4 (which is the -current stable version of Redis). You can optionally run the suite against a Redis instance built from -the `unstable` branch with the development profile by changing the `REDIS_SERVER_VERSION` to `dev` in -the `phpunit.xml` file. More details on testing Predis can be found in [the tests README](tests/README.md). +suite is configured to execute integration tests using the profile for Redis v2.4 (which is the current +stable version of Redis). You can optionally run the suite against a Redis instance built from the `unstable` +branch with the development profile by changing the `REDIS_SERVER_VERSION` to `dev` in the `phpunit.xml` +file. More details on testing Predis can be found in [the tests README](tests/README.md). Predis uses Travis CI for continuous integration. You can find the results of the test suite and the build history [on its project page](http://travis-ci.org/nrk/predis). diff --git a/examples/MasterSlaveReplicationComplex.php b/examples/MasterSlaveReplicationComplex.php index 786d595c..bc5fa83a 100644 --- a/examples/MasterSlaveReplicationComplex.php +++ b/examples/MasterSlaveReplicationComplex.php @@ -20,7 +20,6 @@ require 'SharedConfigurations.php'; use Predis\Command\ScriptedCommand; use Predis\Connection\MasterSlaveReplication; -use Predis\Profile\ServerProfile; use Predis\Replication\ReplicationStrategy; // ------------------------------------------------------------------------- // diff --git a/lib/Predis/Client.php b/lib/Predis/Client.php index 7874e799..d93e0922 100644 --- a/lib/Predis/Client.php +++ b/lib/Predis/Client.php @@ -22,7 +22,6 @@ use Predis\Connection\ConnectionInterface; use Predis\Connection\ConnectionParametersInterface; use Predis\Monitor; use Predis\Pipeline; -use Predis\Profile\ServerProfile; use Predis\PubSub; use Predis\Response; use Predis\Transaction; diff --git a/lib/Predis/ClientInterface.php b/lib/Predis/ClientInterface.php index 42e01232..71d20826 100644 --- a/lib/Predis/ClientInterface.php +++ b/lib/Predis/ClientInterface.php @@ -11,9 +11,10 @@ namespace Predis; +use Predis\Command\CommandInterface; use Predis\Configuration\OptionsInterface; use Predis\Connection\ConnectionInterface; -use Predis\Profile\ServerProfileInterface; +use Predis\Profile\ProfileInterface; /** * Interface defining the most important parts needed to create an @@ -27,7 +28,7 @@ interface ClientInterface extends BasicClientInterface /** * Returns the server profile used by the client. * - * @return ServerProfileInterface + * @return ProfileInterface */ public function getProfile(); @@ -60,7 +61,7 @@ interface ClientInterface extends BasicClientInterface * * @param string $method The name of a Redis command. * @param array $arguments The arguments for the command. - * @return Command\CommandInterface + * @return CommandInterface */ public function createCommand($method, $arguments = array()); } diff --git a/lib/Predis/Configuration/ProfileOption.php b/lib/Predis/Configuration/ProfileOption.php index 4847d2ee..47d19aae 100644 --- a/lib/Predis/Configuration/ProfileOption.php +++ b/lib/Predis/Configuration/ProfileOption.php @@ -12,8 +12,7 @@ namespace Predis\Configuration; use InvalidArgumentException; -use Predis\Profile\ServerProfile; -use Predis\Profile\ServerProfileInterface; +use Predis\Profile; /** * Configures the server profile to be used by the client @@ -28,9 +27,9 @@ class ProfileOption implements OptionInterface * Sets the needed commands processors that should be applied to the profile. * * @param OptionsInterface $options Client options. - * @param ServerProfileInterface $profile Server profile. + * @param Profile\ProfileInterface $profile Server profile. */ - protected function setProcessors(OptionsInterface $options, ServerProfileInterface $profile) + protected function setProcessors(OptionsInterface $options, Profile\ProfileInterface $profile) { if (isset($options->prefix)) { $profile->setProcessor($options->prefix); @@ -43,9 +42,9 @@ class ProfileOption implements OptionInterface public function filter(OptionsInterface $options, $value) { if (is_string($value)) { - $value = ServerProfile::get($value); + $value = Profile\Factory::get($value); $this->setProcessors($options, $value); - } else if (!$value instanceof ServerProfileInterface) { + } else if (!$value instanceof Profile\ProfileInterface) { throw new InvalidArgumentException('Invalid value for the profile option'); } @@ -57,7 +56,7 @@ class ProfileOption implements OptionInterface */ public function getDefault(OptionsInterface $options) { - $profile = ServerProfile::getDefault(); + $profile = Profile\Factory::getDefault(); $this->setProcessors($options, $profile); return $profile; diff --git a/lib/Predis/Connection/ConnectionFactory.php b/lib/Predis/Connection/ConnectionFactory.php index 56c5232c..b705b735 100644 --- a/lib/Predis/Connection/ConnectionFactory.php +++ b/lib/Predis/Connection/ConnectionFactory.php @@ -11,8 +11,7 @@ namespace Predis\Connection; -use Predis\Profile\ServerProfile; -use Predis\Profile\ServerProfileInterface; +use Predis\Profile; /** * Provides a default factory for Redis connections that maps URI schemes @@ -28,9 +27,9 @@ class ConnectionFactory implements ConnectionFactoryInterface /** * Initializes a new instance of the default connection factory class used by Predis. * - * @param ServerProfileInterface $profile Server profile used to initialize new connections. + * @param Profile\ProfileInterface $profile Server profile used to initialize new connections. */ - public function __construct(ServerProfileInterface $profile = null) + public function __construct(Profile\ProfileInterface $profile = null) { $this->schemes = $this->getDefaultSchemes(); $this->profile = $profile; @@ -160,9 +159,9 @@ class ConnectionFactory implements ConnectionFactoryInterface /** * Sets the server profile used to create initialization commands for connections. * - * @param ServerProfileInterface $profile Server profile instance. + * @param Profile\ProfileInterface $profile Server profile instance. */ - public function setProfile(ServerProfileInterface $profile) + public function setProfile(Profile\ProfileInterface $profile) { $this->profile = $profile; } @@ -170,7 +169,7 @@ class ConnectionFactory implements ConnectionFactoryInterface /** * Returns the server profile used to create initialization commands for connections. * - * @return ServerProfileInterface + * @return Profile\ProfileInterface */ public function getProfile() { diff --git a/lib/Predis/Pipeline/Atomic.php b/lib/Predis/Pipeline/Atomic.php index 226fc0aa..cd7236a7 100644 --- a/lib/Predis/Pipeline/Atomic.php +++ b/lib/Predis/Pipeline/Atomic.php @@ -15,7 +15,7 @@ use SplQueue; use Predis\ClientException; use Predis\Connection\ConnectionInterface; use Predis\Connection\SingleConnectionInterface; -use Predis\Profile\ServerProfileInterface; +use Predis\Profile; use Predis\Response; /** @@ -89,9 +89,9 @@ class Atomic extends Pipeline * Verifies all the needed preconditions before executing the pipeline. * * @param ConnectionInterface $connection Connection instance. - * @param ServerProfileInterface $profile Server profile. + * @param Profile\ProfileInterface $profile Server profile. */ - protected function check(ConnectionInterface $connection, ServerProfileInterface $profile) + protected function check(ConnectionInterface $connection, Profile\ProfileInterface $profile) { if (!$connection instanceof SingleConnectionInterface) { $class = __CLASS__; diff --git a/lib/Predis/Profile/Factory.php b/lib/Predis/Profile/Factory.php new file mode 100644 index 00000000..24a26bb8 --- /dev/null +++ b/lib/Predis/Profile/Factory.php @@ -0,0 +1,97 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +use InvalidArgumentException; +use ReflectionClass; +use Predis\ClientException; + +/** + * Base class that implements common functionalities of server profiles. + * + * @author Daniele Alessandri + */ +final class Factory +{ + private static $profiles = array( + '1.2' => 'Predis\Profile\RedisVersion120', + '2.0' => 'Predis\Profile\RedisVersion200', + '2.2' => 'Predis\Profile\RedisVersion220', + '2.4' => 'Predis\Profile\RedisVersion240', + '2.6' => 'Predis\Profile\RedisVersion260', + '2.8' => 'Predis\Profile\RedisVersion280', + 'default' => 'Predis\Profile\RedisVersion280', + 'dev' => 'Predis\Profile\RedisUnstable', + ); + + /** + * + */ + private function __construct() + { + // NOOP + } + + /** + * Returns the default server profile. + * + * @return ProfileInterface + */ + public static function getDefault() + { + return self::get('default'); + } + + /** + * Returns the development server profile. + * + * @return ProfileInterface + */ + public static function getDevelopment() + { + return self::get('dev'); + } + + /** + * Registers a new server profile. + * + * @param string $alias Profile version or alias. + * @param string $profileClass FQN of a class implementing Predis\Profile\ProfileInterface. + */ + public static function define($alias, $profileClass) + { + $reflection = new ReflectionClass($profileClass); + + if (!$reflection->isSubclassOf('Predis\Profile\ProfileInterface')) { + throw new InvalidArgumentException("Cannot register '$profileClass' as it is not a valid profile class"); + } + + self::$profiles[$alias] = $profileClass; + } + + /** + * Returns the specified server profile. + * + * @param string $version Profile version or alias. + * @return ProfileInterface + */ + public static function get($version) + { + if (!isset(self::$profiles[$version])) { + throw new ClientException("Unknown server profile: $version"); + } + + $profile = self::$profiles[$version]; + + return new $profile(); + } +} diff --git a/lib/Predis/Profile/ServerProfileInterface.php b/lib/Predis/Profile/ProfileInterface.php similarity index 57% rename from lib/Predis/Profile/ServerProfileInterface.php rename to lib/Predis/Profile/ProfileInterface.php index 0329723c..4a2b7c4c 100644 --- a/lib/Predis/Profile/ServerProfileInterface.php +++ b/lib/Predis/Profile/ProfileInterface.php @@ -14,16 +14,16 @@ namespace Predis\Profile; use Predis\Command\CommandInterface; /** - * A server profile defines features and commands supported by certain - * versions of Redis. Instances of Predis\Client should use a server - * profile matching the version of Redis in use. + * A profile defines all the features and commands supported by certain versions + * of Redis. Instances of Predis\Client should use a server profile matching the + * version of Redis being used. * * @author Daniele Alessandri */ -interface ServerProfileInterface +interface ProfileInterface { /** - * Gets a profile version corresponding to a Redis version. + * Returns the profile version corresponding to the Redis version. * * @return string */ @@ -32,25 +32,25 @@ interface ServerProfileInterface /** * Checks if the profile supports the specified command. * - * @param string $command Command ID. + * @param string $commandID Command ID. * @return Boolean */ - public function supportsCommand($command); + public function supportsCommand($commandID); /** * Checks if the profile supports the specified list of commands. * - * @param array $commands List of command IDs. + * @param array $commandIDs List of command IDs. * @return string */ - public function supportsCommands(array $commands); + public function supportsCommands(array $commandIDs); /** * Creates a new command instance. * - * @param string $method Command ID. + * @param string $commandID Command ID. * @param array $arguments Arguments for the command. * @return CommandInterface */ - public function createCommand($method, $arguments = array()); + public function createCommand($commandID, $arguments = array()); } diff --git a/lib/Predis/Profile/RedisProfile.php b/lib/Predis/Profile/RedisProfile.php new file mode 100644 index 00000000..37ab3391 --- /dev/null +++ b/lib/Predis/Profile/RedisProfile.php @@ -0,0 +1,146 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +use InvalidArgumentException; +use ReflectionClass; +use Predis\ClientException; +use Predis\Command\Processor\CommandProcessingInterface; +use Predis\Command\Processor\CommandProcessorInterface; + +/** + * Base class that implements common functionalities of server profiles. + * + * @author Daniele Alessandri + */ +abstract class RedisProfile implements ProfileInterface, CommandProcessingInterface +{ + private $commands; + private $processor; + + /** + * + */ + public function __construct() + { + $this->commands = $this->getSupportedCommands(); + } + + /** + * Returns a map of all the commands supported by the profile and their + * actual PHP classes. + * + * @return array + */ + protected abstract function getSupportedCommands(); + + /** + * {@inheritdoc} + */ + public function supportsCommand($commandID) + { + return isset($this->commands[strtolower($commandID)]); + } + + /** + * {@inheritdoc} + */ + public function supportsCommands(array $commandIDs) + { + foreach ($commandIDs as $commandID) { + if (!$this->supportsCommand($commandID)) { + return false; + } + } + + return true; + } + + /** + * Returns the FQN of the class that represent the specified command ID + * registered in the current server profile. + * + * @param string $commandID Command ID. + * @return string + */ + public function getCommandClass($commandID) + { + if (isset($this->commands[$commandID = strtolower($commandID)])) { + return $this->commands[$commandID]; + } + } + + /** + * {@inheritdoc} + */ + public function createCommand($commandID, $arguments = array()) + { + $commandID = strtolower($commandID); + + if (!isset($this->commands[$commandID])) { + throw new ClientException("'$commandID' is not a registered Redis command"); + } + + $commandClass = $this->commands[$commandID]; + $command = new $commandClass(); + $command->setArguments($arguments); + + if (isset($this->processor)) { + $this->processor->process($command); + } + + return $command; + } + + /** + * Defines a new commands in the server profile. + * + * @param string $commandID Command ID. + * @param string $commandClass FQN of a class implementing Predis\Command\CommandInterface. + */ + public function defineCommand($commandID, $commandClass) + { + $reflection = new ReflectionClass($commandClass); + + if (!$reflection->isSubclassOf('Predis\Command\CommandInterface')) { + throw new InvalidArgumentException("Cannot register '$commandClass' as it is not a valid Redis command"); + } + + $this->commands[strtolower($commandID)] = $commandClass; + } + + /** + * {@inheritdoc} + */ + public function setProcessor(CommandProcessorInterface $processor = null) + { + $this->processor = $processor; + } + + /** + * {@inheritdoc} + */ + public function getProcessor() + { + return $this->processor; + } + + /** + * Returns the version of server profile as its string representation. + * + * @return string + */ + public function __toString() + { + return $this->getVersion(); + } +} diff --git a/lib/Predis/Profile/ServerVersionNext.php b/lib/Predis/Profile/RedisUnstable.php similarity index 93% rename from lib/Predis/Profile/ServerVersionNext.php rename to lib/Predis/Profile/RedisUnstable.php index e98c3549..ed8b6242 100644 --- a/lib/Predis/Profile/ServerVersionNext.php +++ b/lib/Predis/Profile/RedisUnstable.php @@ -16,7 +16,7 @@ namespace Predis\Profile; * * @author Daniele Alessandri */ -class ServerVersionNext extends ServerVersion28 +class RedisUnstable extends RedisVersion280 { /** * {@inheritdoc} diff --git a/lib/Predis/Profile/ServerVersion12.php b/lib/Predis/Profile/RedisVersion120.php similarity index 99% rename from lib/Predis/Profile/ServerVersion12.php rename to lib/Predis/Profile/RedisVersion120.php index 4e339a7c..85652dfb 100644 --- a/lib/Predis/Profile/ServerVersion12.php +++ b/lib/Predis/Profile/RedisVersion120.php @@ -16,7 +16,7 @@ namespace Predis\Profile; * * @author Daniele Alessandri */ -class ServerVersion12 extends ServerProfile +class RedisVersion120 extends RedisProfile { /** * {@inheritdoc} diff --git a/lib/Predis/Profile/ServerVersion20.php b/lib/Predis/Profile/RedisVersion200.php similarity index 99% rename from lib/Predis/Profile/ServerVersion20.php rename to lib/Predis/Profile/RedisVersion200.php index 42b0b088..9eb5c51d 100644 --- a/lib/Predis/Profile/ServerVersion20.php +++ b/lib/Predis/Profile/RedisVersion200.php @@ -16,7 +16,7 @@ namespace Predis\Profile; * * @author Daniele Alessandri */ -class ServerVersion20 extends ServerProfile +class RedisVersion200 extends RedisProfile { /** * {@inheritdoc} diff --git a/lib/Predis/Profile/ServerVersion22.php b/lib/Predis/Profile/RedisVersion220.php similarity index 99% rename from lib/Predis/Profile/ServerVersion22.php rename to lib/Predis/Profile/RedisVersion220.php index e97f422b..8641c9f3 100644 --- a/lib/Predis/Profile/ServerVersion22.php +++ b/lib/Predis/Profile/RedisVersion220.php @@ -16,7 +16,7 @@ namespace Predis\Profile; * * @author Daniele Alessandri */ -class ServerVersion22 extends ServerProfile +class RedisVersion220 extends RedisProfile { /** * {@inheritdoc} diff --git a/lib/Predis/Profile/ServerVersion24.php b/lib/Predis/Profile/RedisVersion240.php similarity index 99% rename from lib/Predis/Profile/ServerVersion24.php rename to lib/Predis/Profile/RedisVersion240.php index 20569c6f..918c2b0b 100644 --- a/lib/Predis/Profile/ServerVersion24.php +++ b/lib/Predis/Profile/RedisVersion240.php @@ -16,7 +16,7 @@ namespace Predis\Profile; * * @author Daniele Alessandri */ -class ServerVersion24 extends ServerProfile +class RedisVersion240 extends RedisProfile { /** * {@inheritdoc} diff --git a/lib/Predis/Profile/ServerVersion26.php b/lib/Predis/Profile/RedisVersion260.php similarity index 99% rename from lib/Predis/Profile/ServerVersion26.php rename to lib/Predis/Profile/RedisVersion260.php index c3471f84..59e956b2 100644 --- a/lib/Predis/Profile/ServerVersion26.php +++ b/lib/Predis/Profile/RedisVersion260.php @@ -16,7 +16,7 @@ namespace Predis\Profile; * * @author Daniele Alessandri */ -class ServerVersion26 extends ServerProfile +class RedisVersion260 extends RedisProfile { /** * {@inheritdoc} diff --git a/lib/Predis/Profile/ServerVersion28.php b/lib/Predis/Profile/RedisVersion280.php similarity index 99% rename from lib/Predis/Profile/ServerVersion28.php rename to lib/Predis/Profile/RedisVersion280.php index 2664cc2d..92ebac6d 100644 --- a/lib/Predis/Profile/ServerVersion28.php +++ b/lib/Predis/Profile/RedisVersion280.php @@ -16,7 +16,7 @@ namespace Predis\Profile; * * @author Daniele Alessandri */ -class ServerVersion28 extends ServerProfile +class RedisVersion280 extends RedisProfile { /** * {@inheritdoc} diff --git a/lib/Predis/Profile/ServerProfile.php b/lib/Predis/Profile/ServerProfile.php deleted file mode 100644 index 7f2fc60c..00000000 --- a/lib/Predis/Profile/ServerProfile.php +++ /dev/null @@ -1,228 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -use Predis\ClientException; -use Predis\Command\Processor\CommandProcessingInterface; -use Predis\Command\Processor\CommandProcessorInterface; - -/** - * Base class that implements common functionalities of server profiles. - * - * @author Daniele Alessandri - */ -abstract class ServerProfile implements ServerProfileInterface, CommandProcessingInterface -{ - private static $profiles; - - private $commands; - private $processor; - - /** - * - */ - public function __construct() - { - $this->commands = $this->getSupportedCommands(); - } - - /** - * Returns a map of all the commands supported by the profile and their - * actual PHP classes. - * - * @return array - */ - protected abstract function getSupportedCommands(); - - /** - * Returns the default server profile. - * - * @return ServerProfileInterface - */ - public static function getDefault() - { - return self::get('default'); - } - - /** - * Returns the development server profile. - * - * @return ServerProfileInterface - */ - public static function getDevelopment() - { - return self::get('dev'); - } - - /** - * Returns a map of all the server profiles supported by default and their - * actual PHP classes. - * - * @return array - */ - private static function getDefaultProfiles() - { - return array( - '1.2' => 'Predis\Profile\ServerVersion12', - '2.0' => 'Predis\Profile\ServerVersion20', - '2.2' => 'Predis\Profile\ServerVersion22', - '2.4' => 'Predis\Profile\ServerVersion24', - '2.6' => 'Predis\Profile\ServerVersion26', - '2.8' => 'Predis\Profile\ServerVersion28', - 'default' => 'Predis\Profile\ServerVersion28', - 'dev' => 'Predis\Profile\ServerVersionNext', - ); - } - - /** - * Registers a new server profile. - * - * @param string $alias Profile version or alias. - * @param string $profileClass FQN of a class implementing Predis\Profile\ServerProfileInterface. - */ - public static function define($alias, $profileClass) - { - if (!isset(self::$profiles)) { - self::$profiles = self::getDefaultProfiles(); - } - - $profileReflection = new \ReflectionClass($profileClass); - - if (!$profileReflection->isSubclassOf('Predis\Profile\ServerProfileInterface')) { - throw new \InvalidArgumentException("Cannot register '$profileClass' as it is not a valid profile class"); - } - - self::$profiles[$alias] = $profileClass; - } - - /** - * Returns the specified server profile. - * - * @param string $version Profile version or alias. - * @return ServerProfileInterface - */ - public static function get($version) - { - if (!isset(self::$profiles)) { - self::$profiles = self::getDefaultProfiles(); - } - - if (!isset(self::$profiles[$version])) { - throw new ClientException("Unknown server profile: $version"); - } - - $profile = self::$profiles[$version]; - - return new $profile(); - } - - /** - * {@inheritdoc} - */ - public function supportsCommands(array $commands) - { - foreach ($commands as $command) { - if (!$this->supportsCommand($command)) { - return false; - } - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function supportsCommand($command) - { - return isset($this->commands[strtolower($command)]); - } - - /** - * Returns the FQN of the class that represent the specified command ID - * registered in the current server profile. - * - * @param string $command Command ID. - * @return string - */ - public function getCommandClass($command) - { - if (isset($this->commands[$command = strtolower($command)])) { - return $this->commands[$command]; - } - } - - /** - * {@inheritdoc} - */ - public function createCommand($method, $arguments = array()) - { - $method = strtolower($method); - - if (!isset($this->commands[$method])) { - throw new ClientException("'$method' is not a registered Redis command"); - } - - $commandClass = $this->commands[$method]; - $command = new $commandClass(); - $command->setArguments($arguments); - - if (isset($this->processor)) { - $this->processor->process($command); - } - - return $command; - } - - /** - * Defines a new commands in the server profile. - * - * @param string $alias Command ID. - * @param string $command FQN of a class implementing Predis\Command\CommandInterface. - */ - public function defineCommand($alias, $command) - { - $commandReflection = new \ReflectionClass($command); - - if (!$commandReflection->isSubclassOf('Predis\Command\CommandInterface')) { - throw new \InvalidArgumentException("Cannot register '$command' as it is not a valid Redis command"); - } - - $this->commands[strtolower($alias)] = $command; - } - - /** - * {@inheritdoc} - */ - public function setProcessor(CommandProcessorInterface $processor = null) - { - $this->processor = $processor; - } - - /** - * {@inheritdoc} - */ - public function getProcessor() - { - return $this->processor; - } - - /** - * Returns the version of server profile as its string representation. - * - * @return string - */ - public function __toString() - { - return $this->getVersion(); - } -} diff --git a/tests/PHPUnit/CommandTestCase.php b/tests/PHPUnit/CommandTestCase.php index 39c87cb7..1866b45e 100644 --- a/tests/PHPUnit/CommandTestCase.php +++ b/tests/PHPUnit/CommandTestCase.php @@ -14,8 +14,7 @@ namespace Predis\Command; use PHPUnit_Framework_TestCase as StandardTestCase; use Predis\Client; -use Predis\Profile\ServerProfile; -use Predis\Profile\ServerProfileInterface; +use Predis\Profile; /** * @@ -51,11 +50,11 @@ abstract class CommandTestCase extends StandardTestCase /** * Return the server profile used during the tests. * - * @return ServerProfileInterface + * @return Profile\ProfileInterface */ protected function getProfile() { - return ServerProfile::get(REDIS_SERVER_VERSION); + return Profile\Factory::get(REDIS_SERVER_VERSION); } /** diff --git a/tests/PHPUnit/ConnectionTestCase.php b/tests/PHPUnit/ConnectionTestCase.php index e673f582..83fb40bd 100644 --- a/tests/PHPUnit/ConnectionTestCase.php +++ b/tests/PHPUnit/ConnectionTestCase.php @@ -13,7 +13,7 @@ namespace Predis\Connection; use PHPUnit_Framework_TestCase as StandardTestCase; -use Predis\Profile\ServerProfile; +use Predis\Profile; /** * @group realm-connection @@ -340,17 +340,17 @@ abstract class ConnectionTestCase extends StandardTestCase * Returns a new instance of server profile. * * @param array $additional Additional connection parameters. - * @return ServerProfile + * @return Profile\ProfileInterface */ protected function getProfile($version = null) { - return ServerProfile::get($version ?: REDIS_SERVER_VERSION); + return Profile\Factory::get($version ?: REDIS_SERVER_VERSION); } /** * Returns a new instance of a connection instance. * - * @param ServerProfile $profile Reference to the server profile instance. + * @param Profile\ProfileInterface $profile Reference to the server profile instance. * @param Boolean $initialize Push default initialization commands (SELECT and FLUSHDB). * @param array $parameters Additional connection parameters. * @return StreamConnection diff --git a/tests/Predis/Profile/ServerProfileTest.php b/tests/PHPUnit/RedisProfileTestCase.php similarity index 67% rename from tests/Predis/Profile/ServerProfileTest.php rename to tests/PHPUnit/RedisProfileTestCase.php index 8485add7..a6d47b8e 100644 --- a/tests/Predis/Profile/ServerProfileTest.php +++ b/tests/PHPUnit/RedisProfileTestCase.php @@ -18,81 +18,63 @@ use Predis\Command\Processor\ProcessorChain; /** * */ -class ServerProfileTest extends StandardTestCase +abstract class RedisProfileTestCase extends StandardTestCase { - const DEFAULT_PROFILE_VERSION = '2.8'; - const DEVELOPMENT_PROFILE_VERSION = '3.0'; + /** + * Returns a new instance of the tested profile. + * + * @return ProfileInterface + */ + protected abstract function getProfileInstance(); + + /** + * Returns the expected version string for the tested profile. + * + * @return string Version string. + */ + protected abstract function getExpectedVersion(); + + /** + * Returns the expected list of commands supported by the tested profile. + * + * @return array List of supported commands. + */ + protected abstract function getExpectedCommands(); + + /** + * Returns the list of commands supported by the current + * server profile. + * + * @param ProfileInterface $profile Server profile instance. + * @return array + */ + protected function getCommands(ProfileInterface $profile) + { + $commands = $profile->getSupportedCommands(); + + return array_keys($commands); + } /** * @group disconnected */ public function testGetVersion() { - $profile = ServerProfile::get('2.0'); + $profile = $this->getProfileInstance(); - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); - $this->assertEquals('2.0', $profile->getVersion()); + $this->assertEquals($this->getExpectedVersion(), $profile->getVersion()); } /** * @group disconnected */ - public function testGetDefault() + public function testSupportedCommands() { - $profile1 = ServerProfile::get(self::DEFAULT_PROFILE_VERSION); - $profile2 = ServerProfile::get('default'); - $profile3 = ServerProfile::getDefault(); + $profile = $this->getProfileInstance(); + $expected = $this->getExpectedCommands(); + $commands = $this->getCommands($profile); - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile1); - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile2); - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile3); - $this->assertEquals($profile1->getVersion(), $profile2->getVersion()); - $this->assertEquals($profile2->getVersion(), $profile3->getVersion()); - } - - /** - * @group disconnected - */ - public function testGetDevelopment() - { - $profile1 = ServerProfile::get('dev'); - $profile2 = ServerProfile::getDevelopment(); - - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile1); - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile2); - $this->assertEquals(self::DEVELOPMENT_PROFILE_VERSION, $profile2->getVersion()); - } - - /** - * @group disconnected - * @expectedException Predis\ClientException - * @expectedExceptionMessage Unknown server profile: 1.0 - */ - public function testGetUndefinedProfile() - { - ServerProfile::get('1.0'); - } - - /** - * @group disconnected - */ - public function testDefineProfile() - { - $profileClass = get_class($this->getMock('Predis\Profile\ServerProfileInterface')); - - ServerProfile::define('mock', $profileClass); - - $this->assertInstanceOf($profileClass, ServerProfile::get('mock')); - } - - /** - * @group disconnected - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Cannot register 'stdClass' as it is not a valid profile class - */ - public function testDefineInvalidProfile() - { - ServerProfile::define('bogus', 'stdClass'); + $this->assertSame($expected, $commands); } /** @@ -100,7 +82,7 @@ class ServerProfileTest extends StandardTestCase */ public function testToString() { - $this->assertEquals('2.0', (string) ServerProfile::get('2.0')); + $this->assertEquals($this->getExpectedVersion(), $this->getProfileInstance()); } /** @@ -108,7 +90,7 @@ class ServerProfileTest extends StandardTestCase */ public function testSupportCommand() { - $profile = ServerProfile::getDefault(); + $profile = $this->getProfileInstance(); $this->assertTrue($profile->supportsCommand('info')); $this->assertTrue($profile->supportsCommand('INFO')); @@ -122,7 +104,7 @@ class ServerProfileTest extends StandardTestCase */ public function testSupportCommands() { - $profile = ServerProfile::getDefault(); + $profile = $this->getProfileInstance(); $this->assertTrue($profile->supportsCommands(array('get', 'set'))); $this->assertTrue($profile->supportsCommands(array('GET', 'SET'))); @@ -137,7 +119,7 @@ class ServerProfileTest extends StandardTestCase */ public function testGetCommandClass() { - $profile = ServerProfile::getDefault(); + $profile = $this->getProfileInstance(); $this->assertSame('Predis\Command\ConnectionPing', $profile->getCommandClass('ping')); $this->assertSame('Predis\Command\ConnectionPing', $profile->getCommandClass('PING')); @@ -151,7 +133,7 @@ class ServerProfileTest extends StandardTestCase */ public function testDefineCommand() { - $profile = ServerProfile::getDefault(); + $profile = $this->getProfileInstance(); $command = $this->getMock('Predis\Command\CommandInterface'); $profile->defineCommand('mock', get_class($command)); @@ -169,7 +151,7 @@ class ServerProfileTest extends StandardTestCase */ public function testDefineInvalidCommand() { - $profile = ServerProfile::getDefault(); + $profile = $this->getProfileInstance(); $profile->defineCommand('mock', 'stdClass'); } @@ -179,7 +161,7 @@ class ServerProfileTest extends StandardTestCase */ public function testCreateCommandWithoutArguments() { - $profile = ServerProfile::getDefault(); + $profile = $this->getProfileInstance(); $command = $profile->createCommand('info'); $this->assertInstanceOf('Predis\Command\CommandInterface', $command); @@ -192,7 +174,7 @@ class ServerProfileTest extends StandardTestCase */ public function testCreateCommandWithArguments() { - $profile = ServerProfile::getDefault(); + $profile = $this->getProfileInstance(); $arguments = array('foo', 'bar'); $command = $profile->createCommand('set', $arguments); @@ -208,7 +190,7 @@ class ServerProfileTest extends StandardTestCase */ public function testCreateUndefinedCommand() { - $profile = ServerProfile::getDefault(); + $profile = $this->getProfileInstance(); $profile->createCommand('unknown'); } @@ -217,7 +199,7 @@ class ServerProfileTest extends StandardTestCase */ public function testGetDefaultProcessor() { - $profile = ServerProfile::getDefault(); + $profile = $this->getProfileInstance(); $this->assertNull($profile->getProcessor()); } @@ -229,7 +211,7 @@ class ServerProfileTest extends StandardTestCase { $processor = $this->getMock('Predis\Command\Processor\CommandProcessorInterface'); - $profile = ServerProfile::getDefault(); + $profile = $this->getProfileInstance(); $profile->setProcessor($processor); $this->assertSame($processor, $profile->getProcessor()); @@ -241,7 +223,7 @@ class ServerProfileTest extends StandardTestCase public function testSetAndUnsetProcessor() { $processor = $this->getMock('Predis\Command\Processor\CommandProcessorInterface'); - $profile = ServerProfile::getDefault(); + $profile = $this->getProfileInstance(); $profile->setProcessor($processor); $this->assertSame($processor, $profile->getProcessor()); @@ -267,7 +249,7 @@ class ServerProfileTest extends StandardTestCase $cmd->setRawArguments($argsRef = array_map('strtoupper', $cmd->getArguments())); })); - $profile = ServerProfile::getDefault(); + $profile = $this->getProfileInstance(); $profile->setProcessor($processor); $command = $profile->createCommand('set', array('foo', 'bar')); @@ -287,7 +269,7 @@ class ServerProfileTest extends StandardTestCase $chain->add($processor); $chain->add($processor); - $profile = ServerProfile::getDefault(); + $profile = $this->getProfileInstance(); $profile->setProcessor($chain); $profile->createCommand('info'); } diff --git a/tests/PHPUnit/ServerVersionTestCase.php b/tests/PHPUnit/ServerVersionTestCase.php deleted file mode 100644 index e3012d8c..00000000 --- a/tests/PHPUnit/ServerVersionTestCase.php +++ /dev/null @@ -1,77 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -use PHPUnit_Framework_TestCase as StandardTestCase; - -/** - * - */ -abstract class ServerVersionTestCase extends StandardTestCase -{ - /** - * Returns a new instance of the tested profile. - * - * @return ServerProfileInterface - */ - protected abstract function getProfileInstance(); - - /** - * Returns the expected version string for the tested profile. - * - * @return string Version string. - */ - protected abstract function getExpectedVersion(); - - /** - * Returns the expected list of commands supported by the tested profile. - * - * @return array List of supported commands. - */ - protected abstract function getExpectedCommands(); - - /** - * Returns the list of commands supported by the current - * server profile. - * - * @param ServerProfileInterface $profile Server profile instance. - * @return array - */ - protected function getCommands(ServerProfileInterface $profile) - { - $commands = $profile->getSupportedCommands(); - - return array_keys($commands); - } - - /** - * @group disconnected - */ - public function testGetVersion() - { - $profile = $this->getProfileInstance(); - - $this->assertEquals($this->getExpectedVersion(), $profile->getVersion()); - } - - /** - * @group disconnected - */ - public function testSupportedCommands() - { - $profile = $this->getProfileInstance(); - $expected = $this->getExpectedCommands(); - $commands = $this->getCommands($profile); - - $this->assertSame($expected, $commands); - } -} diff --git a/tests/Predis/ClientTest.php b/tests/Predis/ClientTest.php index a33bbaef..6297fb28 100644 --- a/tests/Predis/ClientTest.php +++ b/tests/Predis/ClientTest.php @@ -16,7 +16,7 @@ use PHPUnit_Framework_TestCase as StandardTestCase; use Predis\Connection\ConnectionFactory; use Predis\Connection\MasterSlaveReplication; use Predis\Connection\PredisCluster; -use Predis\Profile\ServerProfile; +use Predis\Profile; use Predis\Response; /** @@ -39,7 +39,7 @@ class ClientTest extends StandardTestCase $this->assertSame($parameters->port, 6379); $options = $client->getOptions(); - $this->assertSame($options->profile->getVersion(), ServerProfile::getDefault()->getVersion()); + $this->assertSame($options->profile->getVersion(), Profile\Factory::getDefault()->getVersion()); $this->assertFalse($client->isConnected()); } @@ -59,7 +59,7 @@ class ClientTest extends StandardTestCase $this->assertSame($parameters->port, 6379); $options = $client->getOptions(); - $this->assertSame($options->profile->getVersion(), ServerProfile::getDefault()->getVersion()); + $this->assertSame($options->profile->getVersion(), Profile\Factory::getDefault()->getVersion()); $this->assertFalse($client->isConnected()); } @@ -79,7 +79,7 @@ class ClientTest extends StandardTestCase $this->assertSame($parameters->port, 6379); $options = $client->getOptions(); - $this->assertSame($options->profile->getVersion(), ServerProfile::getDefault()->getVersion()); + $this->assertSame($options->profile->getVersion(), Profile\Factory::getDefault()->getVersion()); $this->assertFalse($client->isConnected()); } @@ -245,7 +245,7 @@ class ClientTest extends StandardTestCase $client = new Client(null, $arg2); $profile = $client->getProfile(); - $this->assertSame($profile->getVersion(), ServerProfile::get('2.0')->getVersion()); + $this->assertSame($profile->getVersion(), Profile\Factory::get('2.0')->getVersion()); $this->assertInstanceOf('Predis\Command\Processor\KeyPrefixProcessor', $profile->getProcessor()); $this->assertSame('prefix:', $profile->getProcessor()->getPrefix()); } @@ -359,9 +359,9 @@ class ClientTest extends StandardTestCase */ public function testCreatesNewCommandUsingSpecifiedProfile() { - $ping = ServerProfile::getDefault()->createCommand('ping', array()); + $ping = Profile\Factory::getDefault()->createCommand('ping', array()); - $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); + $profile = $this->getMock('Predis\Profile\ProfileInterface'); $profile->expects($this->once()) ->method('createCommand') ->with('ping', array()) @@ -376,7 +376,7 @@ class ClientTest extends StandardTestCase */ public function testExecuteCommandReturnsParsedReplies() { - $profile = ServerProfile::getDefault(); + $profile = Profile\Factory::getDefault(); $ping = $profile->createCommand('ping', array()); $hgetall = $profile->createCommand('hgetall', array('metavars', 'foo', 'hoge')); @@ -404,7 +404,7 @@ class ClientTest extends StandardTestCase */ public function testExecuteCommandThrowsExceptionOnRedisError() { - $ping = ServerProfile::getDefault()->createCommand('ping', array()); + $ping = Profile\Factory::getDefault()->createCommand('ping', array()); $expectedResponse = new Response\Error('ERR Operation against a key holding the wrong kind of value'); $connection= $this->getMock('Predis\Connection\ConnectionInterface'); @@ -421,7 +421,7 @@ class ClientTest extends StandardTestCase */ public function testExecuteCommandReturnsErrorResponseOnRedisError() { - $ping = ServerProfile::getDefault()->createCommand('ping', array()); + $ping = Profile\Factory::getDefault()->createCommand('ping', array()); $expectedResponse = new Response\Error('ERR Operation against a key holding the wrong kind of value'); $connection= $this->getMock('Predis\Connection\ConnectionInterface'); @@ -440,7 +440,7 @@ class ClientTest extends StandardTestCase */ public function testCallingRedisCommandExecutesInstanceOfCommand() { - $ping = ServerProfile::getDefault()->createCommand('ping', array()); + $ping = Profile\Factory::getDefault()->createCommand('ping', array()); $connection = $this->getMock('Predis\Connection\ConnectionInterface'); $connection->expects($this->once()) @@ -448,7 +448,7 @@ class ClientTest extends StandardTestCase ->with($this->isInstanceOf('Predis\Command\ConnectionPing')) ->will($this->returnValue('PONG')); - $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); + $profile = $this->getMock('Predis\Profile\ProfileInterface'); $profile->expects($this->once()) ->method('createCommand') ->with('ping', array()) diff --git a/tests/Predis/Cluster/PredisStrategyTest.php b/tests/Predis/Cluster/PredisStrategyTest.php index 8609869d..025256b9 100644 --- a/tests/Predis/Cluster/PredisStrategyTest.php +++ b/tests/Predis/Cluster/PredisStrategyTest.php @@ -13,7 +13,7 @@ namespace Predis\Cluster; use PHPUnit_Framework_TestCase as StandardTestCase; -use Predis\Profile\ServerProfile; +use Predis\Profile; /** * @@ -55,7 +55,7 @@ class PredisStrategyTest extends StandardTestCase public function testReturnsNullOnUnsupportedCommand() { $strategy = $this->getClusterStrategy(); - $command = ServerProfile::getDevelopment()->createCommand('ping'); + $command = Profile\Factory::getDevelopment()->createCommand('ping'); $this->assertNull($strategy->getHash($command)); } @@ -66,7 +66,7 @@ class PredisStrategyTest extends StandardTestCase public function testFirstKeyCommands() { $strategy = $this->getClusterStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $arguments = array('key'); foreach ($this->getExpectedCommands('keys-first') as $commandID) { @@ -81,7 +81,7 @@ class PredisStrategyTest extends StandardTestCase public function testAllKeysCommands() { $strategy = $this->getClusterStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $arguments = array('{key}:1', '{key}:2', '{key}:3', '{key}:4'); foreach ($this->getExpectedCommands('keys-all') as $commandID) { @@ -96,7 +96,7 @@ class PredisStrategyTest extends StandardTestCase public function testInterleavedKeysCommands() { $strategy = $this->getClusterStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $arguments = array('{key}:1', 'value1', '{key}:2', 'value2'); foreach ($this->getExpectedCommands('keys-interleaved') as $commandID) { @@ -111,7 +111,7 @@ class PredisStrategyTest extends StandardTestCase public function testKeysForBlockingListCommands() { $strategy = $this->getClusterStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $arguments = array('{key}:1', '{key}:2', 10); foreach ($this->getExpectedCommands('keys-blockinglist') as $commandID) { @@ -126,7 +126,7 @@ class PredisStrategyTest extends StandardTestCase public function testKeysForZsetAggregationCommands() { $strategy = $this->getClusterStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $arguments = array('{key}:destination', 2, '{key}:1', '{key}:1', array('aggregate' => 'SUM')); foreach ($this->getExpectedCommands('keys-zaggregated') as $commandID) { @@ -141,7 +141,7 @@ class PredisStrategyTest extends StandardTestCase public function testKeysForBitOpCommand() { $strategy = $this->getClusterStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $arguments = array('AND', '{key}:destination', '{key}:src:1', '{key}:src:2'); foreach ($this->getExpectedCommands('keys-bitop') as $commandID) { @@ -156,7 +156,7 @@ class PredisStrategyTest extends StandardTestCase public function testKeysForScriptCommand() { $strategy = $this->getClusterStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $arguments = array('%SCRIPT%', 2, '{key}:1', '{key}:2', 'value1', 'value2'); foreach ($this->getExpectedCommands('keys-script') as $commandID) { @@ -191,7 +191,7 @@ class PredisStrategyTest extends StandardTestCase public function testUnsettingCommandHandler() { $strategy = $this->getClusterStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $strategy->setCommandHandler('set'); $strategy->setCommandHandler('get', null); @@ -209,7 +209,7 @@ class PredisStrategyTest extends StandardTestCase public function testSettingCustomCommandHandler() { $strategy = $this->getClusterStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $callable = $this->getMock('stdClass', array('__invoke')); $callable->expects($this->once()) diff --git a/tests/Predis/Cluster/RedisStrategyTest.php b/tests/Predis/Cluster/RedisStrategyTest.php index 2d1cca01..fc56587a 100644 --- a/tests/Predis/Cluster/RedisStrategyTest.php +++ b/tests/Predis/Cluster/RedisStrategyTest.php @@ -13,7 +13,7 @@ namespace Predis\Cluster; use PHPUnit_Framework_TestCase as StandardTestCase; -use Predis\Profile\ServerProfile; +use Predis\Profile; /** * @@ -49,7 +49,7 @@ class RedisStrategyTest extends StandardTestCase public function testReturnsNullOnUnsupportedCommand() { $strategy = $this->getClusterStrategy(); - $command = ServerProfile::getDevelopment()->createCommand('ping'); + $command = Profile\Factory::getDevelopment()->createCommand('ping'); $this->assertNull($strategy->getHash($command)); } @@ -60,7 +60,7 @@ class RedisStrategyTest extends StandardTestCase public function testFirstKeyCommands() { $strategy = $this->getClusterStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $arguments = array('key'); foreach ($this->getExpectedCommands('keys-first') as $commandID) { @@ -75,7 +75,7 @@ class RedisStrategyTest extends StandardTestCase public function testAllKeysCommandsWithOneKey() { $strategy = $this->getClusterStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $arguments = array('key'); foreach ($this->getExpectedCommands('keys-all') as $commandID) { @@ -90,7 +90,7 @@ class RedisStrategyTest extends StandardTestCase public function testAllKeysCommandsWithMoreKeys() { $strategy = $this->getClusterStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $arguments = array('key1', 'key2'); foreach ($this->getExpectedCommands('keys-all') as $commandID) { @@ -105,7 +105,7 @@ class RedisStrategyTest extends StandardTestCase public function testInterleavedKeysCommandsWithOneKey() { $strategy = $this->getClusterStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $arguments = array('key:1', 'value1'); foreach ($this->getExpectedCommands('keys-interleaved') as $commandID) { @@ -120,7 +120,7 @@ class RedisStrategyTest extends StandardTestCase public function testInterleavedKeysCommandsWithMoreKeys() { $strategy = $this->getClusterStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $arguments = array('key:1', 'value1', 'key:2', 'value2'); foreach ($this->getExpectedCommands('keys-interleaved') as $commandID) { @@ -135,7 +135,7 @@ class RedisStrategyTest extends StandardTestCase public function testKeysForBlockingListCommandsWithOneKey() { $strategy = $this->getClusterStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $arguments = array('key:1', 10); foreach ($this->getExpectedCommands('keys-blockinglist') as $commandID) { @@ -150,7 +150,7 @@ class RedisStrategyTest extends StandardTestCase public function testKeysForBlockingListCommandsWithMoreKeys() { $strategy = $this->getClusterStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $arguments = array('key:1', 'key:2', 10); foreach ($this->getExpectedCommands('keys-blockinglist') as $commandID) { @@ -165,7 +165,7 @@ class RedisStrategyTest extends StandardTestCase public function testKeysForScriptCommand() { $strategy = $this->getClusterStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $arguments = array('%SCRIPT%', 1, 'key:1', 'value1'); foreach ($this->getExpectedCommands('keys-script') as $commandID) { @@ -200,7 +200,7 @@ class RedisStrategyTest extends StandardTestCase public function testUnsettingCommandHandler() { $strategy = $this->getClusterStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $strategy->setCommandHandler('set'); $strategy->setCommandHandler('get', null); @@ -218,7 +218,7 @@ class RedisStrategyTest extends StandardTestCase public function testSettingCustomCommandHandler() { $strategy = $this->getClusterStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $callable = $this->getMock('stdClass', array('__invoke')); $callable->expects($this->once()) diff --git a/tests/Predis/Collection/Iterator/HashKeyTest.php b/tests/Predis/Collection/Iterator/HashKeyTest.php index e2793b87..93f84f89 100644 --- a/tests/Predis/Collection/Iterator/HashKeyTest.php +++ b/tests/Predis/Collection/Iterator/HashKeyTest.php @@ -14,7 +14,7 @@ namespace Predis\Collection\Iterator; use PHPUnit_Framework_TestCase as StandardTestCase; use Predis\Client; -use Predis\Profile\ServerProfile; +use Predis\Profile; /** * @group realm-iterators @@ -26,13 +26,13 @@ class HashKeyTest extends StandardTestCase * @expectedException Predis\NotSupportedException * @expectedExceptionMessage The specified server profile does not support the `HSCAN` command. */ - public function testThrowsExceptionOnInvalidServerProfile() + public function testThrowsExceptionOnInvalidProfile() { $client = $this->getMock('Predis\ClientInterface'); $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.0'))); + ->will($this->returnValue(Profile\Factory::get('2.0'))); $iterator = new HashKey($client, 'key:hash'); } @@ -46,7 +46,7 @@ class HashKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->once()) ->method('hscan') ->with('key:hash', 0, array()) @@ -67,7 +67,7 @@ class HashKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->once()) ->method('hscan') ->with('key:hash', 0, array()) @@ -105,7 +105,7 @@ class HashKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('hscan') ->with('key:hash', 0, array()) @@ -149,7 +149,7 @@ class HashKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('hscan') ->with('key:hash', 0, array()) @@ -186,7 +186,7 @@ class HashKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('hscan') ->with('key:hash', 0, array()) @@ -234,7 +234,7 @@ class HashKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('hscan') ->with('key:hash', 0, array('MATCH' => 'field:*')) @@ -267,7 +267,7 @@ class HashKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('hscan') ->with('key:hash', 0, array('MATCH' => 'field:*')) @@ -306,7 +306,7 @@ class HashKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('hscan') ->with('key:hash', 0, array('COUNT' => 2)) @@ -339,7 +339,7 @@ class HashKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('hscan') ->with('key:hash', 0, array('COUNT' => 1)) @@ -378,7 +378,7 @@ class HashKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('hscan') ->with('key:hash', 0, array('MATCH' => 'field:*', 'COUNT' => 2)) @@ -411,7 +411,7 @@ class HashKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('hscan') ->with('key:hash', 0, array('MATCH' => 'field:*', 'COUNT' => 1)) @@ -450,7 +450,7 @@ class HashKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->exactly(2)) ->method('hscan') ->with('key:hash', 0, array()) diff --git a/tests/Predis/Collection/Iterator/KeyspaceTest.php b/tests/Predis/Collection/Iterator/KeyspaceTest.php index b842e280..2fadaab2 100644 --- a/tests/Predis/Collection/Iterator/KeyspaceTest.php +++ b/tests/Predis/Collection/Iterator/KeyspaceTest.php @@ -14,7 +14,7 @@ namespace Predis\Collection\Iterator; use PHPUnit_Framework_TestCase as StandardTestCase; use Predis\Client; -use Predis\Profile\ServerProfile; +use Predis\Profile; /** * @group realm-iterators @@ -26,13 +26,13 @@ class KeyspaceTest extends StandardTestCase * @expectedException Predis\NotSupportedException * @expectedExceptionMessage The specified server profile does not support the `SCAN` command. */ - public function testThrowsExceptionOnInvalidServerProfile() + public function testThrowsExceptionOnInvalidProfile() { $client = $this->getMock('Predis\ClientInterface'); $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.0'))); + ->will($this->returnValue(Profile\Factory::get('2.0'))); $iterator = new Keyspace($client); } @@ -46,7 +46,7 @@ class KeyspaceTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->once()) ->method('scan') ->with(0, array()) @@ -67,7 +67,7 @@ class KeyspaceTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->once()) ->method('scan') ->with(0, array()) @@ -103,7 +103,7 @@ class KeyspaceTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('scan') ->with(0, array()) @@ -143,7 +143,7 @@ class KeyspaceTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('scan') ->with(0, array()) @@ -178,7 +178,7 @@ class KeyspaceTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('scan') ->with(0, array()) @@ -222,7 +222,7 @@ class KeyspaceTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('scan') ->with(0, array('MATCH' => 'key:*')) @@ -253,7 +253,7 @@ class KeyspaceTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('scan') ->with(0, array('MATCH' => 'key:*')) @@ -288,7 +288,7 @@ class KeyspaceTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('scan') ->with(0, array('COUNT' => 2)) @@ -319,7 +319,7 @@ class KeyspaceTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('scan') ->with(0, array('COUNT' => 1)) @@ -354,7 +354,7 @@ class KeyspaceTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('scan') ->with(0, array('MATCH' => 'key:*', 'COUNT' => 2)) @@ -385,7 +385,7 @@ class KeyspaceTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('scan') ->with(0, array('MATCH' => 'key:*', 'COUNT' => 1)) @@ -420,7 +420,7 @@ class KeyspaceTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->exactly(2)) ->method('scan') ->with(0, array()) diff --git a/tests/Predis/Collection/Iterator/ListKeyTest.php b/tests/Predis/Collection/Iterator/ListKeyTest.php index 56e724ff..e4ff7327 100644 --- a/tests/Predis/Collection/Iterator/ListKeyTest.php +++ b/tests/Predis/Collection/Iterator/ListKeyTest.php @@ -14,7 +14,7 @@ namespace Predis\Collection\Iterator; use PHPUnit_Framework_TestCase as StandardTestCase; use Predis\Client; -use Predis\Profile\ServerProfile; +use Predis\Profile; /** * @group realm-iterators @@ -30,7 +30,7 @@ class ListKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::getDefault())); + ->will($this->returnValue(Profile\Factory::getDefault())); $client->expects($this->once()) ->method('lrange') ->with('key:list', 0, 9) @@ -51,7 +51,7 @@ class ListKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::getDefault())); + ->will($this->returnValue(Profile\Factory::getDefault())); $client->expects($this->once()) ->method('lrange') ->with('key:list', 0, 9) @@ -87,7 +87,7 @@ class ListKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::getDefault())); + ->will($this->returnValue(Profile\Factory::getDefault())); $client->expects($this->at(1)) ->method('lrange') ->with('key:list', 0, 9) @@ -120,7 +120,7 @@ class ListKeyTest extends StandardTestCase $client = $this->getMock('Predis\ClientInterface'); $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::getDefault())); + ->will($this->returnValue(Profile\Factory::getDefault())); $iterator = new ListKey($client, 'key:list', 'wrong'); } @@ -135,7 +135,7 @@ class ListKeyTest extends StandardTestCase $client = $this->getMock('Predis\ClientInterface'); $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::getDefault())); + ->will($this->returnValue(Profile\Factory::getDefault())); $iterator = new ListKey($client, 'key:list', 'wrong'); } @@ -149,7 +149,7 @@ class ListKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::getDefault())); + ->will($this->returnValue(Profile\Factory::getDefault())); $client->expects($this->at(1)) ->method('lrange') ->with('key:list', 0, 4) @@ -180,7 +180,7 @@ class ListKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::getDefault())); + ->will($this->returnValue(Profile\Factory::getDefault())); $client->expects($this->at(1)) ->method('lrange') ->with('key:list', 0, 1) @@ -220,7 +220,7 @@ class ListKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::getDefault())); + ->will($this->returnValue(Profile\Factory::getDefault())); $client->expects($this->exactly(2)) ->method('lrange') ->with('key:list', 0, 9) diff --git a/tests/Predis/Collection/Iterator/SetKeyTest.php b/tests/Predis/Collection/Iterator/SetKeyTest.php index d390c923..43e5edac 100644 --- a/tests/Predis/Collection/Iterator/SetKeyTest.php +++ b/tests/Predis/Collection/Iterator/SetKeyTest.php @@ -14,7 +14,7 @@ namespace Predis\Collection\Iterator; use PHPUnit_Framework_TestCase as StandardTestCase; use Predis\Client; -use Predis\Profile\ServerProfile; +use Predis\Profile; /** * @group realm-iterators @@ -26,13 +26,13 @@ class SetKeyTest extends StandardTestCase * @expectedException Predis\NotSupportedException * @expectedExceptionMessage The specified server profile does not support the `SSCAN` command. */ - public function testThrowsExceptionOnInvalidServerProfile() + public function testThrowsExceptionOnInvalidProfile() { $client = $this->getMock('Predis\ClientInterface'); $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.0'))); + ->will($this->returnValue(Profile\Factory::get('2.0'))); $iterator = new SetKey($client, 'key:set'); } @@ -46,7 +46,7 @@ class SetKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->once()) ->method('sscan') ->with('key:set', 0, array()) @@ -67,7 +67,7 @@ class SetKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->once()) ->method('sscan') ->with('key:set', 0, array()) @@ -103,7 +103,7 @@ class SetKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('sscan') ->with('key:set', 0, array()) @@ -143,7 +143,7 @@ class SetKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('sscan') ->with('key:set', 0, array()) @@ -178,7 +178,7 @@ class SetKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('sscan') ->with('key:set', 0, array()) @@ -222,7 +222,7 @@ class SetKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('sscan') ->with('key:set', 0, array('MATCH' => 'member:*')) @@ -253,7 +253,7 @@ class SetKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('sscan') ->with('key:set', 0, array('MATCH' => 'member:*')) @@ -288,7 +288,7 @@ class SetKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('sscan') ->with('key:set', 0, array('COUNT' => 2)) @@ -319,7 +319,7 @@ class SetKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('sscan') ->with('key:set', 0, array('COUNT' => 1)) @@ -354,7 +354,7 @@ class SetKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('sscan') ->with('key:set', 0, array('MATCH' => 'member:*', 'COUNT' => 2)) @@ -385,7 +385,7 @@ class SetKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('sscan') ->with('key:set', 0, array('MATCH' => 'member:*', 'COUNT' => 1)) @@ -420,7 +420,7 @@ class SetKeyTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->exactly(2)) ->method('sscan') ->with('key:set', 0, array()) diff --git a/tests/Predis/Collection/Iterator/SortedSetKeyTest.php b/tests/Predis/Collection/Iterator/SortedSetKeyTest.php index 48576c42..ae9b5314 100644 --- a/tests/Predis/Collection/Iterator/SortedSetKeyTest.php +++ b/tests/Predis/Collection/Iterator/SortedSetKeyTest.php @@ -14,7 +14,7 @@ namespace Predis\Collection\Iterator; use PHPUnit_Framework_TestCase as StandardTestCase; use Predis\Client; -use Predis\Profile\ServerProfile; +use Predis\Profile; /** * @group realm-iterators @@ -26,13 +26,13 @@ class SortedSetTest extends StandardTestCase * @expectedException Predis\NotSupportedException * @expectedExceptionMessage The specified server profile does not support the `ZSCAN` command. */ - public function testThrowsExceptionOnInvalidServerProfile() + public function testThrowsExceptionOnInvalidProfile() { $client = $this->getMock('Predis\ClientInterface'); $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.0'))); + ->will($this->returnValue(Profile\Factory::get('2.0'))); $iterator = new SortedSetKey($client, 'key:zset'); } @@ -46,7 +46,7 @@ class SortedSetTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->once()) ->method('zscan') ->with('key:zset', 0, array()) @@ -67,7 +67,7 @@ class SortedSetTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->once()) ->method('zscan') ->with('key:zset', 0, array()) @@ -105,7 +105,7 @@ class SortedSetTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('zscan') ->with('key:zset', 0, array()) @@ -149,7 +149,7 @@ class SortedSetTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('zscan') ->with('key:zset', 0, array()) @@ -186,7 +186,7 @@ class SortedSetTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('zscan') ->with('key:zset', 0, array()) @@ -234,7 +234,7 @@ class SortedSetTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('zscan') ->with('key:zset', 0, array('MATCH' => 'member:*')) @@ -267,7 +267,7 @@ class SortedSetTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('zscan') ->with('key:zset', 0, array('MATCH' => 'member:*')) @@ -306,7 +306,7 @@ class SortedSetTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('zscan') ->with('key:zset', 0, array('COUNT' => 2)) @@ -339,7 +339,7 @@ class SortedSetTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('zscan') ->with('key:zset', 0, array('COUNT' => 1)) @@ -378,7 +378,7 @@ class SortedSetTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('zscan') ->with('key:zset', 0, array('MATCH' => 'member:*', 'COUNT' => 2)) @@ -411,7 +411,7 @@ class SortedSetTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->at(1)) ->method('zscan') ->with('key:zset', 0, array('MATCH' => 'member:*', 'COUNT' => 1)) @@ -450,7 +450,7 @@ class SortedSetTest extends StandardTestCase $client->expects($this->any()) ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); + ->will($this->returnValue(Profile\Factory::get('2.8'))); $client->expects($this->exactly(2)) ->method('zscan') ->with('key:zset', 0, array()) diff --git a/tests/Predis/Configuration/OptionsTest.php b/tests/Predis/Configuration/OptionsTest.php index 6a8f0f22..69628fea 100644 --- a/tests/Predis/Configuration/OptionsTest.php +++ b/tests/Predis/Configuration/OptionsTest.php @@ -28,7 +28,7 @@ class OptionsTest extends StandardTestCase $options = new Options(); $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $options->connections); - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $options->profile); + $this->assertInstanceOf('Predis\Profile\ProfileInterface', $options->profile); $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $options->cluster); $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $options->replication); $this->assertTrue($options->exceptions); @@ -50,7 +50,7 @@ class OptionsTest extends StandardTestCase )); $this->assertInternalType('bool', $options->exceptions); - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $options->profile); + $this->assertInstanceOf('Predis\Profile\ProfileInterface', $options->profile); $this->assertInstanceOf('Predis\Command\Processor\CommandProcessorInterface', $options->prefix); $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $options->connections); $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $options->cluster); @@ -122,7 +122,7 @@ class OptionsTest extends StandardTestCase { $options = new Options(); - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $options->getDefault('profile')); + $this->assertInstanceOf('Predis\Profile\ProfileInterface', $options->getDefault('profile')); } /** @@ -140,7 +140,7 @@ class OptionsTest extends StandardTestCase */ public function testLazilyInitializesOptionValueUsingObjectWithInvokeMagicMethod() { - $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); + $profile = $this->getMock('Predis\Profile\ProfileInterface'); // NOTE: closure values are covered by this test since they define __invoke(). $callable = $this->getMock('stdClass', array('__invoke')); diff --git a/tests/Predis/Configuration/ProfileOptionTest.php b/tests/Predis/Configuration/ProfileOptionTest.php index 6364881e..93078093 100644 --- a/tests/Predis/Configuration/ProfileOptionTest.php +++ b/tests/Predis/Configuration/ProfileOptionTest.php @@ -16,7 +16,7 @@ use PHPUnit_Framework_TestCase as StandardTestCase; use stdClass; use Predis\Command\Processor\KeyPrefixProcessor; -use Predis\Profile\ServerProfile; +use Predis\Profile; /** * @@ -33,19 +33,19 @@ class ProfileOptionTest extends StandardTestCase $profile = $option->getDefault($options); - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); - $this->assertInstanceOf(get_class(ServerProfile::getDefault()), $profile); + $this->assertInstanceOf('Predis\Profile\ProfileInterface', $profile); + $this->assertInstanceOf(get_class(Profile\Factory::getDefault()), $profile); $this->assertNull($profile->getProcessor()); } /** * @group disconnected */ - public function testAcceptsServerProfileInstanceAsValue() + public function testAcceptsProfileInstanceAsValue() { $option = new ProfileOption(); $options = $this->getMock('Predis\Configuration\OptionsInterface'); - $value = ServerProfile::get('2.0'); + $value = Profile\Factory::get('2.0'); $profile = $option->filter($options, $value); @@ -56,14 +56,14 @@ class ProfileOptionTest extends StandardTestCase /** * @group disconnected */ - public function testAcceptsStringInterpretedAsServerProfileVersion() + public function testAcceptsStringInterpretedAsProfileVersion() { $option = new ProfileOption(); $options = $this->getMock('Predis\Configuration\OptionsInterface'); $profile = $option->filter($options, '2.0'); - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); + $this->assertInstanceOf('Predis\Profile\ProfileInterface', $profile); $this->assertEquals('2.0', $profile->getVersion()); $this->assertNull($profile->getProcessor()); } @@ -87,8 +87,8 @@ class ProfileOptionTest extends StandardTestCase $profile = $option->getDefault($options); - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); - $this->assertInstanceOf(get_class(ServerProfile::getDefault()), $profile); + $this->assertInstanceOf('Predis\Profile\ProfileInterface', $profile); + $this->assertInstanceOf(get_class(Profile\Factory::getDefault()), $profile); $this->assertInstanceOf('Predis\Command\Processor\KeyPrefixProcessor', $profile->getProcessor()); $this->assertSame('prefix:', $profile->getProcessor()->getPrefix()); @@ -113,8 +113,8 @@ class ProfileOptionTest extends StandardTestCase $profile = $option->filter($options, '2.0'); - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); - $this->assertInstanceOf(get_class(ServerProfile::get('2.0')), $profile); + $this->assertInstanceOf('Predis\Profile\ProfileInterface', $profile); + $this->assertInstanceOf(get_class(Profile\Factory::get('2.0')), $profile); $this->assertInstanceOf('Predis\Command\Processor\KeyPrefixProcessor', $profile->getProcessor()); $this->assertSame('prefix:', $profile->getProcessor()->getPrefix()); @@ -123,19 +123,19 @@ class ProfileOptionTest extends StandardTestCase /** * @group disconnected */ - public function testDoesNotApplyPrefixOnServerProfileValue() + public function testDoesNotApplyPrefixOnProfileValue() { $option = new ProfileOption(); $options = $this->getMock('Predis\Configuration\OptionsInterface'); - $value = ServerProfile::getDefault(); + $value = Profile\Factory::getDefault(); $options->expects($this->never())->method('__isset'); $options->expects($this->never())->method('__get'); $profile = $option->filter($options, $value); - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); - $this->assertInstanceOf(get_class(ServerProfile::getDefault()), $profile); + $this->assertInstanceOf('Predis\Profile\ProfileInterface', $profile); + $this->assertInstanceOf(get_class(Profile\Factory::getDefault()), $profile); $this->assertNull($profile->getProcessor()); } diff --git a/tests/Predis/Connection/ComposableStreamConnectionTest.php b/tests/Predis/Connection/ComposableStreamConnectionTest.php index fde10dc6..114f6ee7 100644 --- a/tests/Predis/Connection/ComposableStreamConnectionTest.php +++ b/tests/Predis/Connection/ComposableStreamConnectionTest.php @@ -13,8 +13,6 @@ namespace Predis\Connection; use PHPUnit_Framework_TestCase as StandardTestCase; -use Predis\Profile\ServerProfile; - /** * */ diff --git a/tests/Predis/Connection/ConnectionFactoryTest.php b/tests/Predis/Connection/ConnectionFactoryTest.php index 68f9169d..891d69da 100644 --- a/tests/Predis/Connection/ConnectionFactoryTest.php +++ b/tests/Predis/Connection/ConnectionFactoryTest.php @@ -113,7 +113,7 @@ class ConnectionFactoryTest extends StandardTestCase */ public function testCreateConnectionWithoutInitializationCommands() { - $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); + $profile = $this->getMock('Predis\Profile\ProfileInterface'); $profile->expects($this->never())->method('create'); $factory = new ConnectionFactory($profile); @@ -140,7 +140,7 @@ class ConnectionFactoryTest extends StandardTestCase return $command; }; - $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); + $profile = $this->getMock('Predis\Profile\ProfileInterface'); $profile->expects($this->exactly(2)) ->method('createCommand') ->with($this->isType('string'), $this->isType('array')) @@ -347,12 +347,12 @@ class ConnectionFactoryTest extends StandardTestCase * @group disconnected * @todo We might want to add a test for SingleConnectionInterface::pushInitCommand(). */ - public function testAggregatedConnectionWithServerProfileArgument() + public function testAggregatedConnectionWithProfileArgument() { list(, $connectionClass) = $this->getMockConnectionClass(); $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface'); - $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); + $profile = $this->getMock('Predis\Profile\ProfileInterface'); $factory = $this->getMock('Predis\Connection\ConnectionFactory', array('create'), array($profile)); $factory->expects($this->exactly(2)) diff --git a/tests/Predis/Connection/MasterSlaveReplicationTest.php b/tests/Predis/Connection/MasterSlaveReplicationTest.php index 302e9891..57d5336b 100644 --- a/tests/Predis/Connection/MasterSlaveReplicationTest.php +++ b/tests/Predis/Connection/MasterSlaveReplicationTest.php @@ -13,7 +13,7 @@ namespace Predis\Connection; use PHPUnit_Framework_TestCase as StandardTestCase; -use Predis\Profile\ServerProfile; +use Predis\Profile; use Predis\Replication\ReplicationStrategy; /** @@ -217,7 +217,7 @@ class MasterSlaveReplicationTest extends StandardTestCase */ public function testUsesSlavesOnReadOnlyCommands() { - $profile = ServerProfile::getDefault(); + $profile = Profile\Factory::getDefault(); $master = $this->getMockConnection('tcp://host1?alias=master'); $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); @@ -238,7 +238,7 @@ class MasterSlaveReplicationTest extends StandardTestCase */ public function testUsesMasterOnWriteCommands() { - $profile = ServerProfile::getDefault(); + $profile = Profile\Factory::getDefault(); $master = $this->getMockConnection('tcp://host1?alias=master'); $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); @@ -259,7 +259,7 @@ class MasterSlaveReplicationTest extends StandardTestCase */ public function testSwitchesFromSlaveToMasterOnWriteCommands() { - $profile = ServerProfile::getDefault(); + $profile = Profile\Factory::getDefault(); $master = $this->getMockConnection('tcp://host1?alias=master'); $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); @@ -283,9 +283,9 @@ class MasterSlaveReplicationTest extends StandardTestCase */ public function testWritesCommandToCorrectConnection() { - $profile = ServerProfile::getDefault(); + $profile = Profile\Factory::getDefault(); $cmdExists = $profile->createCommand('exists', array('foo')); - $cmdSet = $profile->getDefault()->createCommand('set', array('foo', 'bar')); + $cmdSet = $profile->createCommand('set', array('foo', 'bar')); $master = $this->getMockConnection('tcp://host1?alias=master'); $master->expects($this->once())->method('writeCommand')->with($cmdSet); @@ -306,9 +306,9 @@ class MasterSlaveReplicationTest extends StandardTestCase */ public function testReadsCommandFromCorrectConnection() { - $profile = ServerProfile::getDefault(); + $profile = Profile\Factory::getDefault(); $cmdExists = $profile->createCommand('exists', array('foo')); - $cmdSet = $profile->getDefault()->createCommand('set', array('foo', 'bar')); + $cmdSet = $profile->createCommand('set', array('foo', 'bar')); $master = $this->getMockConnection('tcp://host1?alias=master'); $master->expects($this->once())->method('readResponse')->with($cmdSet); @@ -329,9 +329,9 @@ class MasterSlaveReplicationTest extends StandardTestCase */ public function testExecutesCommandOnCorrectConnection() { - $profile = ServerProfile::getDefault(); + $profile = Profile\Factory::getDefault(); $cmdExists = $profile->createCommand('exists', array('foo')); - $cmdSet = $profile->getDefault()->createCommand('set', array('foo', 'bar')); + $cmdSet = $profile->createCommand('set', array('foo', 'bar')); $master = $this->getMockConnection('tcp://host1?alias=master'); $master->expects($this->once())->method('executeCommand')->with($cmdSet); @@ -352,7 +352,7 @@ class MasterSlaveReplicationTest extends StandardTestCase */ public function testWatchTriggersSwitchToMasterConnection() { - $profile = ServerProfile::getDefault(); + $profile = Profile\Factory::getDefault(); $cmdWatch = $profile->createCommand('watch', array('foo')); $master = $this->getMockConnection('tcp://host1?alias=master'); @@ -373,7 +373,7 @@ class MasterSlaveReplicationTest extends StandardTestCase */ public function testMultiTriggersSwitchToMasterConnection() { - $profile = ServerProfile::getDefault(); + $profile = Profile\Factory::getDefault(); $cmdMulti = $profile->createCommand('multi'); $master = $this->getMockConnection('tcp://host1?alias=master'); @@ -394,7 +394,7 @@ class MasterSlaveReplicationTest extends StandardTestCase */ public function testEvalTriggersSwitchToMasterConnection() { - $profile = ServerProfile::get('dev'); + $profile = Profile\Factory::get('dev'); $cmdEval = $profile->createCommand('eval', array("return redis.call('info')")); $master = $this->getMockConnection('tcp://host1?alias=master'); @@ -415,7 +415,7 @@ class MasterSlaveReplicationTest extends StandardTestCase */ public function testSortTriggersSwitchToMasterConnectionOnStoreModifier() { - $profile = ServerProfile::get('dev'); + $profile = Profile\Factory::get('dev'); $cmdSortNormal = $profile->createCommand('sort', array('key')); $cmdSortStore = $profile->createCommand('sort', array('key', array('store' => 'key:store'))); @@ -440,7 +440,7 @@ class MasterSlaveReplicationTest extends StandardTestCase */ public function testThrowsExceptionOnNonSupportedCommand() { - $cmd = ServerProfile::getDefault()->createCommand('info'); + $cmd = Profile\Factory::getDefault()->createCommand('info'); $replication = new MasterSlaveReplication(); $replication->add($this->getMockConnection('tcp://host1?alias=master')); @@ -454,7 +454,7 @@ class MasterSlaveReplicationTest extends StandardTestCase */ public function testCanOverrideReadOnlyFlagForCommands() { - $profile = ServerProfile::getDefault(); + $profile = Profile\Factory::getDefault(); $cmdSet = $profile->createCommand('set', array('foo', 'bar')); $cmdGet = $profile->createCommand('get', array('foo')); @@ -480,7 +480,7 @@ class MasterSlaveReplicationTest extends StandardTestCase */ public function testAcceptsCallableToOverrideReadOnlyFlagForCommands() { - $profile = ServerProfile::getDefault(); + $profile = Profile\Factory::getDefault(); $cmdExistsFoo = $profile->createCommand('exists', array('foo')); $cmdExistsBar = $profile->createCommand('exists', array('bar')); @@ -508,7 +508,7 @@ class MasterSlaveReplicationTest extends StandardTestCase */ public function testCanSetReadOnlyFlagForEvalScripts() { - $profile = ServerProfile::get('dev'); + $profile = Profile\Factory::get('dev'); $cmdEval = $profile->createCommand('eval', array($script = "return redis.call('info');")); $cmdEvalSha = $profile->createCommand('evalsha', array($scriptSHA1 = sha1($script))); diff --git a/tests/Predis/Connection/PhpiredisConnectionTest.php b/tests/Predis/Connection/PhpiredisConnectionTest.php index c6ccd234..b4a715c1 100644 --- a/tests/Predis/Connection/PhpiredisConnectionTest.php +++ b/tests/Predis/Connection/PhpiredisConnectionTest.php @@ -13,8 +13,6 @@ namespace Predis\Connection; use PHPUnit_Framework_TestCase as StandardTestCase; -use Predis\Profile\ServerProfile; - /** * @group ext-phpiredis */ diff --git a/tests/Predis/Connection/PhpiredisStreamConnectionTest.php b/tests/Predis/Connection/PhpiredisStreamConnectionTest.php index 85ae6a89..796bd22e 100644 --- a/tests/Predis/Connection/PhpiredisStreamConnectionTest.php +++ b/tests/Predis/Connection/PhpiredisStreamConnectionTest.php @@ -13,8 +13,6 @@ namespace Predis\Connection; use PHPUnit_Framework_TestCase as StandardTestCase; -use Predis\Profile\ServerProfile; - /** * @group ext-phpiredis */ diff --git a/tests/Predis/Connection/PredisClusterTest.php b/tests/Predis/Connection/PredisClusterTest.php index 2ea8d446..99f4faba 100644 --- a/tests/Predis/Connection/PredisClusterTest.php +++ b/tests/Predis/Connection/PredisClusterTest.php @@ -13,7 +13,7 @@ namespace Predis\Connection; use PHPUnit_Framework_TestCase as StandardTestCase; -use Predis\Profile\ServerProfile; +use Predis\Profile; /** * @@ -224,7 +224,7 @@ class PredisClusterTest extends StandardTestCase */ public function testReturnsCorrectConnectionUsingCommandInstance() { - $profile = ServerProfile::getDefault(); + $profile = Profile\Factory::getDefault(); $connection1 = $this->getMockConnection('tcp://host1:7001'); $connection2 = $this->getMockConnection('tcp://host1:7002'); @@ -261,7 +261,7 @@ class PredisClusterTest extends StandardTestCase */ public function testThrowsExceptionOnNonShardableCommand() { - $ping = ServerProfile::getDefault()->createCommand('ping'); + $ping = Profile\Factory::getDefault()->createCommand('ping'); $cluster = new PredisCluster(); $cluster->add($this->getMockConnection()); @@ -274,7 +274,7 @@ class PredisClusterTest extends StandardTestCase */ public function testWritesCommandToCorrectConnection() { - $command = ServerProfile::getDefault()->createCommand('get', array('node01:5431')); + $command = Profile\Factory::getDefault()->createCommand('get', array('node01:5431')); $connection1 = $this->getMockConnection('tcp://host1:7001'); $connection1->expects($this->once())->method('writeCommand')->with($command); @@ -294,7 +294,7 @@ class PredisClusterTest extends StandardTestCase */ public function testReadsCommandFromCorrectConnection() { - $command = ServerProfile::getDefault()->createCommand('get', array('node02:3212')); + $command = Profile\Factory::getDefault()->createCommand('get', array('node02:3212')); $connection1 = $this->getMockConnection('tcp://host1:7001'); $connection1->expects($this->never())->method('readResponse'); @@ -314,7 +314,7 @@ class PredisClusterTest extends StandardTestCase */ public function testExecutesCommandOnCorrectConnection() { - $command = ServerProfile::getDefault()->createCommand('get', array('node01:5431')); + $command = Profile\Factory::getDefault()->createCommand('get', array('node01:5431')); $connection1 = $this->getMockConnection('tcp://host1:7001'); $connection1->expects($this->once())->method('executeCommand')->with($command); @@ -334,7 +334,7 @@ class PredisClusterTest extends StandardTestCase */ public function testExecuteCommandOnEachNode() { - $ping = ServerProfile::getDefault()->createCommand('ping', array()); + $ping = Profile\Factory::getDefault()->createCommand('ping', array()); $connection1 = $this->getMock('Predis\Connection\SingleConnectionInterface'); $connection1->expects($this->once()) diff --git a/tests/Predis/Connection/RedisClusterTest.php b/tests/Predis/Connection/RedisClusterTest.php index df74b9c1..60251e2c 100644 --- a/tests/Predis/Connection/RedisClusterTest.php +++ b/tests/Predis/Connection/RedisClusterTest.php @@ -13,7 +13,7 @@ namespace Predis\Connection; use PHPUnit_Framework_TestCase as StandardTestCase; -use Predis\Profile\ServerProfile; +use Predis\Profile; use Predis\Response; /** @@ -326,7 +326,7 @@ class RedisClusterTest extends StandardTestCase */ public function testReturnsCorrectConnectionUsingCommandInstance() { - $profile = ServerProfile::getDefault(); + $profile = Profile\Factory::getDefault(); $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); @@ -358,7 +358,7 @@ class RedisClusterTest extends StandardTestCase */ public function testWritesCommandToCorrectConnection() { - $command = ServerProfile::getDefault()->createCommand('get', array('node:1001')); + $command = Profile\Factory::getDefault()->createCommand('get', array('node:1001')); $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); $connection1->expects($this->once())->method('writeCommand')->with($command); @@ -378,7 +378,7 @@ class RedisClusterTest extends StandardTestCase */ public function testReadsCommandFromCorrectConnection() { - $command = ServerProfile::getDefault()->createCommand('get', array('node:1050')); + $command = Profile\Factory::getDefault()->createCommand('get', array('node:1050')); $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); $connection1->expects($this->never())->method('readResponse'); @@ -398,7 +398,7 @@ class RedisClusterTest extends StandardTestCase */ public function testDoesNotSupportKeyTags() { - $profile = ServerProfile::getDefault(); + $profile = Profile\Factory::getDefault(); $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); @@ -425,7 +425,7 @@ class RedisClusterTest extends StandardTestCase { $askResponse = new Response\Error('ASK 1970 127.0.0.1:6380'); - $command = ServerProfile::getDefault()->createCommand('get', array('node:1001')); + $command = Profile\Factory::getDefault()->createCommand('get', array('node:1001')); $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); $connection1->expects($this->exactly(2)) @@ -458,7 +458,7 @@ class RedisClusterTest extends StandardTestCase { $askResponse = new Response\Error('ASK 1970 127.0.0.1:6381'); - $command = ServerProfile::getDefault()->createCommand('get', array('node:1001')); + $command = Profile\Factory::getDefault()->createCommand('get', array('node:1001')); $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); $connection1->expects($this->exactly(2)) @@ -498,7 +498,7 @@ class RedisClusterTest extends StandardTestCase { $movedResponse = new Response\Error('MOVED 1970 127.0.0.1:6380'); - $command = ServerProfile::getDefault()->createCommand('get', array('node:1001')); + $command = Profile\Factory::getDefault()->createCommand('get', array('node:1001')); $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); $connection1->expects($this->exactly(1)) @@ -532,7 +532,7 @@ class RedisClusterTest extends StandardTestCase { $movedResponse = new Response\Error('MOVED 1970 127.0.0.1:6381'); - $command = ServerProfile::getDefault()->createCommand('get', array('node:1001')); + $command = Profile\Factory::getDefault()->createCommand('get', array('node:1001')); $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); $connection1->expects($this->once()) @@ -572,7 +572,7 @@ class RedisClusterTest extends StandardTestCase */ public function testThrowsExceptionOnNonSupportedCommand() { - $ping = ServerProfile::getDefault()->createCommand('ping'); + $ping = Profile\Factory::getDefault()->createCommand('ping'); $cluster = new RedisCluster(); $cluster->add($this->getMockConnection('tcp://127.0.0.1:6379')); diff --git a/tests/Predis/Connection/StreamConnectionTest.php b/tests/Predis/Connection/StreamConnectionTest.php index b147c7bd..d56440c5 100644 --- a/tests/Predis/Connection/StreamConnectionTest.php +++ b/tests/Predis/Connection/StreamConnectionTest.php @@ -13,8 +13,6 @@ namespace Predis\Connection; use PHPUnit_Framework_TestCase as StandardTestCase; -use Predis\Profile\ServerProfile; - /** * */ diff --git a/tests/Predis/Connection/WebdisConnectionTest.php b/tests/Predis/Connection/WebdisConnectionTest.php index 98864373..793a70ed 100644 --- a/tests/Predis/Connection/WebdisConnectionTest.php +++ b/tests/Predis/Connection/WebdisConnectionTest.php @@ -13,7 +13,7 @@ namespace Predis\Connection; use PHPUnit_Framework_TestCase as StandardTestCase; -use Predis\Profile\ServerProfile; +use Predis\Profile; /** * @group ext-curl @@ -185,11 +185,11 @@ class WebdisConnectionTest extends StandardTestCase * Returns a new instance of server profile. * * @param array $additional Additional connection parameters. - * @return ServerProfile + * @return Profile\ProfileInterface */ protected function getProfile($version = null) { - return ServerProfile::get($version ?: REDIS_SERVER_VERSION); + return Profile\Factory::get($version ?: REDIS_SERVER_VERSION); } /** diff --git a/tests/Predis/Monitor/ConsumerTest.php b/tests/Predis/Monitor/ConsumerTest.php index a825ae6c..edd3c0f4 100644 --- a/tests/Predis/Monitor/ConsumerTest.php +++ b/tests/Predis/Monitor/ConsumerTest.php @@ -14,7 +14,7 @@ namespace Predis\Monitor; use PHPUnit_Framework_TestCase as StandardTestCase; use Predis\Client; -use Predis\Profile\ServerProfile; +use Predis\Profile; use Predis\Monitor\Consumer as MonitorConsumer; /** @@ -29,7 +29,7 @@ class ConsumerTest extends StandardTestCase */ public function testMonitorConsumerRequireMonitorCommand() { - $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); + $profile = $this->getMock('Predis\Profile\ProfileInterface'); $profile->expects($this->once()) ->method('supportsCommand') ->with('monitor') @@ -57,7 +57,7 @@ class ConsumerTest extends StandardTestCase */ public function testConstructorStartsConsumer() { - $cmdMonitor = ServerProfile::getDefault()->createCommand('monitor'); + $cmdMonitor = Profile\Factory::getDefault()->createCommand('monitor'); $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); diff --git a/tests/Predis/Pipeline/FireAndForgetTest.php b/tests/Predis/Pipeline/FireAndForgetTest.php index 7b5d5dd7..8df51f89 100644 --- a/tests/Predis/Pipeline/FireAndForgetTest.php +++ b/tests/Predis/Pipeline/FireAndForgetTest.php @@ -15,7 +15,7 @@ use PHPUnit_Framework_TestCase as StandardTestCase; use SplQueue; use Predis\Client; -use Predis\Profile\ServerProfile; +use Predis\Profile; /** * @@ -27,7 +27,7 @@ class FireAndForgetTest extends StandardTestCase */ public function testPipelineWithSingleConnection() { - $profile = ServerProfile::getDefault(); + $profile = Profile\Factory::getDefault(); $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); $connection->expects($this->exactly(3))->method('writeCommand'); @@ -47,7 +47,7 @@ class FireAndForgetTest extends StandardTestCase */ public function testSwitchesToMasterWithReplicationConnection() { - $profile = ServerProfile::getDefault(); + $profile = Profile\Factory::getDefault(); $connection = $this->getMock('Predis\Connection\ReplicationConnectionInterface'); $connection->expects($this->once()) diff --git a/tests/Predis/Pipeline/PipelineTest.php b/tests/Predis/Pipeline/PipelineTest.php index f4669ecb..c635c854 100644 --- a/tests/Predis/Pipeline/PipelineTest.php +++ b/tests/Predis/Pipeline/PipelineTest.php @@ -15,7 +15,7 @@ use PHPUnit_Framework_TestCase as StandardTestCase; use Predis\Client; use Predis\ClientException; -use Predis\Profile\ServerProfile; +use Predis\Profile; use Predis\Response; /** @@ -133,7 +133,7 @@ class PipelineTest extends StandardTestCase */ public function testExecuteCommandDoesNotSendCommandsWithoutExecute() { - $profile = ServerProfile::getDefault(); + $profile = Profile\Factory::getDefault(); $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); $connection->expects($this->never())->method('writeCommand'); diff --git a/tests/Predis/Profile/FactoryTest.php b/tests/Predis/Profile/FactoryTest.php new file mode 100644 index 00000000..26d61c60 --- /dev/null +++ b/tests/Predis/Profile/FactoryTest.php @@ -0,0 +1,97 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +use PHPUnit_Framework_TestCase as StandardTestCase; + +use Predis\Command\Processor\ProcessorChain; + +/** + * + */ +class FactoryTest extends StandardTestCase +{ + const DEFAULT_PROFILE_VERSION = '2.8'; + const DEVELOPMENT_PROFILE_VERSION = '3.0'; + + /** + * @group disconnected + */ + public function testGetVersion() + { + $profile = Factory::get('2.0'); + + $this->assertInstanceOf('Predis\Profile\ProfileInterface', $profile); + $this->assertEquals('2.0', $profile->getVersion()); + } + + /** + * @group disconnected + */ + public function testGetDefault() + { + $profile1 = Factory::get(self::DEFAULT_PROFILE_VERSION); + $profile2 = Factory::get('default'); + $profile3 = Factory::getDefault(); + + $this->assertInstanceOf('Predis\Profile\ProfileInterface', $profile1); + $this->assertInstanceOf('Predis\Profile\ProfileInterface', $profile2); + $this->assertInstanceOf('Predis\Profile\ProfileInterface', $profile3); + $this->assertEquals($profile1->getVersion(), $profile2->getVersion()); + $this->assertEquals($profile2->getVersion(), $profile3->getVersion()); + } + + /** + * @group disconnected + */ + public function testGetDevelopment() + { + $profile1 = Factory::get('dev'); + $profile2 = Factory::getDevelopment(); + + $this->assertInstanceOf('Predis\Profile\ProfileInterface', $profile1); + $this->assertInstanceOf('Predis\Profile\ProfileInterface', $profile2); + $this->assertEquals(self::DEVELOPMENT_PROFILE_VERSION, $profile2->getVersion()); + } + + /** + * @group disconnected + * @expectedException Predis\ClientException + * @expectedExceptionMessage Unknown server profile: 1.0 + */ + public function testGetUndefinedProfile() + { + Factory::get('1.0'); + } + + /** + * @group disconnected + */ + public function testDefineProfile() + { + $profileClass = get_class($this->getMock('Predis\Profile\ProfileInterface')); + + Factory::define('mock', $profileClass); + + $this->assertInstanceOf($profileClass, Factory::get('mock')); + } + + /** + * @group disconnected + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Cannot register 'stdClass' as it is not a valid profile class + */ + public function testDefineInvalidProfile() + { + Factory::define('bogus', 'stdClass'); + } +} diff --git a/tests/Predis/Profile/ServerVersionNextTest.php b/tests/Predis/Profile/RedisUnstableTest.php similarity index 97% rename from tests/Predis/Profile/ServerVersionNextTest.php rename to tests/Predis/Profile/RedisUnstableTest.php index 110573f9..cab7976c 100644 --- a/tests/Predis/Profile/ServerVersionNextTest.php +++ b/tests/Predis/Profile/RedisUnstableTest.php @@ -14,14 +14,14 @@ namespace Predis\Profile; /** * */ -class ServerVersionNextTest extends ServerVersionTestCase +class RedisUnstableTest extends RedisProfileTestCase { /** * {@inheritdoc} */ public function getProfileInstance() { - return new ServerVersionNext(); + return new RedisUnstable(); } /** diff --git a/tests/Predis/Profile/ServerVersion12Test.php b/tests/Predis/Profile/RedisVersion120Test.php similarity index 96% rename from tests/Predis/Profile/ServerVersion12Test.php rename to tests/Predis/Profile/RedisVersion120Test.php index a1747b56..b93b671d 100644 --- a/tests/Predis/Profile/ServerVersion12Test.php +++ b/tests/Predis/Profile/RedisVersion120Test.php @@ -14,14 +14,14 @@ namespace Predis\Profile; /** * */ -class ServerVersion12Test extends ServerVersionTestCase +class RedisVersion120Test extends RedisProfileTestCase { /** * {@inheritdoc} */ public function getProfileInstance() { - return new ServerVersion12(); + return new RedisVersion120(); } /** diff --git a/tests/Predis/Profile/ServerVersion20Test.php b/tests/Predis/Profile/RedisVersion200Test.php similarity index 97% rename from tests/Predis/Profile/ServerVersion20Test.php rename to tests/Predis/Profile/RedisVersion200Test.php index 3b497369..52fb68cf 100644 --- a/tests/Predis/Profile/ServerVersion20Test.php +++ b/tests/Predis/Profile/RedisVersion200Test.php @@ -14,14 +14,14 @@ namespace Predis\Profile; /** * */ -class ServerVersion20Test extends ServerVersionTestCase +class RedisVersion200Test extends RedisProfileTestCase { /** * {@inheritdoc} */ public function getProfileInstance() { - return new ServerVersion20(); + return new RedisVersion200(); } /** diff --git a/tests/Predis/Profile/ServerVersion22Test.php b/tests/Predis/Profile/RedisVersion220Test.php similarity index 97% rename from tests/Predis/Profile/ServerVersion22Test.php rename to tests/Predis/Profile/RedisVersion220Test.php index 00f6e487..2351e004 100644 --- a/tests/Predis/Profile/ServerVersion22Test.php +++ b/tests/Predis/Profile/RedisVersion220Test.php @@ -14,14 +14,14 @@ namespace Predis\Profile; /** * */ -class ServerVersion22Test extends ServerVersionTestCase +class RedisVersion220Test extends RedisProfileTestCase { /** * {@inheritdoc} */ public function getProfileInstance() { - return new ServerVersion22(); + return new RedisVersion220(); } /** diff --git a/tests/Predis/Profile/ServerVersion24Test.php b/tests/Predis/Profile/RedisVersion240Test.php similarity index 97% rename from tests/Predis/Profile/ServerVersion24Test.php rename to tests/Predis/Profile/RedisVersion240Test.php index 5b3bbd94..9617e493 100644 --- a/tests/Predis/Profile/ServerVersion24Test.php +++ b/tests/Predis/Profile/RedisVersion240Test.php @@ -14,14 +14,14 @@ namespace Predis\Profile; /** * */ -class ServerVersion24Test extends ServerVersionTestCase +class RedisVersion240Test extends RedisProfileTestCase { /** * {@inheritdoc} */ public function getProfileInstance() { - return new ServerVersion24(); + return new RedisVersion240(); } /** diff --git a/tests/Predis/Profile/ServerVersion26Test.php b/tests/Predis/Profile/RedisVersion260Test.php similarity index 97% rename from tests/Predis/Profile/ServerVersion26Test.php rename to tests/Predis/Profile/RedisVersion260Test.php index 8d03d063..598434b3 100644 --- a/tests/Predis/Profile/ServerVersion26Test.php +++ b/tests/Predis/Profile/RedisVersion260Test.php @@ -14,14 +14,14 @@ namespace Predis\Profile; /** * */ -class ServerVersion26Test extends ServerVersionTestCase +class RedisVersion260Test extends RedisProfileTestCase { /** * {@inheritdoc} */ public function getProfileInstance() { - return new ServerVersion26(); + return new RedisVersion260(); } /** diff --git a/tests/Predis/Profile/ServerVersion28Test.php b/tests/Predis/Profile/RedisVersion280Test.php similarity index 98% rename from tests/Predis/Profile/ServerVersion28Test.php rename to tests/Predis/Profile/RedisVersion280Test.php index 9fe96987..5d42ef7b 100644 --- a/tests/Predis/Profile/ServerVersion28Test.php +++ b/tests/Predis/Profile/RedisVersion280Test.php @@ -14,14 +14,14 @@ namespace Predis\Profile; /** * */ -class ServerVersion28Test extends ServerVersionTestCase +class RedisVersion280Test extends RedisProfileTestCase { /** * {@inheritdoc} */ public function getProfileInstance() { - return new ServerVersion28(); + return new RedisVersion280(); } /** diff --git a/tests/Predis/PubSub/ConsumerTest.php b/tests/Predis/PubSub/ConsumerTest.php index ecf866fb..82f7a4f4 100644 --- a/tests/Predis/PubSub/ConsumerTest.php +++ b/tests/Predis/PubSub/ConsumerTest.php @@ -14,7 +14,7 @@ namespace Predis\PubSub; use PHPUnit_Framework_TestCase as StandardTestCase; use Predis\Client; -use Predis\Profile\ServerProfile; +use Predis\Profile; use Predis\PubSub\Consumer as PubSubConsumer; /** @@ -29,7 +29,7 @@ class ConsumerTest extends StandardTestCase */ public function testPubSubConsumerRequirePubSubRelatedCommand() { - $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); + $profile = $this->getMock('Predis\Profile\ProfileInterface'); $profile->expects($this->any()) ->method('supportsCommands') ->will($this->returnValue(false)); @@ -69,7 +69,7 @@ class ConsumerTest extends StandardTestCase */ public function testConstructorWithSubscriptionsStartsConsumer() { - $profile = ServerProfile::get(REDIS_SERVER_VERSION); + $profile = Profile\Factory::get(REDIS_SERVER_VERSION); $cmdSubscribe = $profile->createCommand('subscribe', array('channel:foo')); $cmdPsubscribe = $profile->createCommand('psubscribe', array('channels:*')); @@ -111,7 +111,7 @@ class ConsumerTest extends StandardTestCase */ public function testStoppingConsumerWithFalseSendsUnsubscriptions() { - $profile = ServerProfile::get(REDIS_SERVER_VERSION); + $profile = Profile\Factory::get(REDIS_SERVER_VERSION); $classUnsubscribe = $profile->getCommandClass('unsubscribe'); $classPunsubscribe = $profile->getCommandClass('punsubscribe'); diff --git a/tests/Predis/PubSub/DispatcherLoopTest.php b/tests/Predis/PubSub/DispatcherLoopTest.php index c039fa1d..2f74a8dc 100644 --- a/tests/Predis/PubSub/DispatcherLoopTest.php +++ b/tests/Predis/PubSub/DispatcherLoopTest.php @@ -14,7 +14,6 @@ namespace Predis\PubSub; use PHPUnit_Framework_TestCase as StandardTestCase; use Predis\Client; -use Predis\Profile\ServerProfile; /** * @group realm-pubsub diff --git a/tests/Predis/Replication/ReplicationStrategyTest.php b/tests/Predis/Replication/ReplicationStrategyTest.php index 93016c4c..7c9e935a 100644 --- a/tests/Predis/Replication/ReplicationStrategyTest.php +++ b/tests/Predis/Replication/ReplicationStrategyTest.php @@ -14,7 +14,7 @@ namespace Predis\Replication; use PHPUnit_Framework_TestCase as StandardTestCase; use Predis\Command\CommandInterface; -use Predis\Profile\ServerProfile; +use Predis\Profile; /** * @@ -26,7 +26,7 @@ class ReplicationStrategyTest extends StandardTestCase */ public function testReadCommands() { - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $strategy = new ReplicationStrategy(); foreach ($this->getExpectedCommands('read') as $commandId) { @@ -40,7 +40,7 @@ class ReplicationStrategyTest extends StandardTestCase */ public function testWriteCommands() { - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $strategy = new ReplicationStrategy(); foreach ($this->getExpectedCommands('write') as $commandId) { @@ -54,7 +54,7 @@ class ReplicationStrategyTest extends StandardTestCase */ public function testDisallowedCommands() { - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $strategy = new ReplicationStrategy(); foreach ($this->getExpectedCommands('disallowed') as $commandId) { @@ -68,7 +68,7 @@ class ReplicationStrategyTest extends StandardTestCase */ public function testSortCommand() { - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $strategy = new ReplicationStrategy(); $cmdReadSort = $profile->createCommand('SORT', array('key:list')); @@ -85,7 +85,7 @@ class ReplicationStrategyTest extends StandardTestCase */ public function testUsingDisallowedCommandThrowsException() { - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $strategy = new ReplicationStrategy(); $command = $profile->createCommand('INFO'); @@ -150,7 +150,7 @@ class ReplicationStrategyTest extends StandardTestCase public function testCanUseCallableToCheckCommand() { $strategy = new ReplicationStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $strategy->setCommandReadOnly('SET', function ($command) { return $command->getArgument(1) === true; @@ -169,7 +169,7 @@ class ReplicationStrategyTest extends StandardTestCase public function testSetLuaScriptAsReadOperation() { $strategy = new ReplicationStrategy(); - $profile = ServerProfile::getDevelopment(); + $profile = Profile\Factory::getDevelopment(); $writeScript = 'redis.call("set", "foo", "bar")'; $readScript = 'return true'; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 7bcf5b22..efe24915 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -14,5 +14,5 @@ require __DIR__.'/../autoload.php'; require __DIR__.'/PHPUnit/ArrayHasSameValuesConstraint.php'; require __DIR__.'/PHPUnit/CommandTestCase.php'; require __DIR__.'/PHPUnit/ConnectionTestCase.php'; -require __DIR__.'/PHPUnit/ServerVersionTestCase.php'; +require __DIR__.'/PHPUnit/RedisProfileTestCase.php'; require __DIR__.'/PHPUnit/DistributorTestCase.php';