diff --git a/examples/CustomDistributionStrategy.php b/examples/CustomDistributionStrategy.php index 052b6c03..f690379c 100644 --- a/examples/CustomDistributionStrategy.php +++ b/examples/CustomDistributionStrategy.php @@ -13,13 +13,13 @@ require 'SharedConfigurations.php'; // Developers can customize the distribution strategy used by the client // to distribute keys among a cluster of servers simply by creating a class -// that implements Predis\Distribution\DistributionStrategyInterface. +// that implements Predis\Distribution\DistributorInterface. use Predis\Connection\PredisCluster; -use Predis\Cluster\Distribution\DistributionStrategyInterface; +use Predis\Cluster\Distributor\DistributorInterface; use Predis\Cluster\Hash\HashGeneratorInterface; -class NaiveDistributionStrategy implements DistributionStrategyInterface, HashGeneratorInterface +class NaiveDistributor implements DistributorInterface, HashGeneratorInterface { private $nodes; private $nodesCount; @@ -67,7 +67,7 @@ class NaiveDistributionStrategy implements DistributionStrategyInterface, HashGe $options = array( 'cluster' => function () { - $distributor = new NaiveDistributionStrategy(); + $distributor = new NaiveDistributor(); $cluster = new PredisCluster($distributor); return $cluster; diff --git a/lib/Predis/Cluster/Distribution/DistributionStrategyInterface.php b/lib/Predis/Cluster/Distributor/DistributorInterface.php similarity index 83% rename from lib/Predis/Cluster/Distribution/DistributionStrategyInterface.php rename to lib/Predis/Cluster/Distributor/DistributorInterface.php index 2b07936b..ce2af92c 100644 --- a/lib/Predis/Cluster/Distribution/DistributionStrategyInterface.php +++ b/lib/Predis/Cluster/Distributor/DistributorInterface.php @@ -9,17 +9,17 @@ * file that was distributed with this source code. */ -namespace Predis\Cluster\Distribution; +namespace Predis\Cluster\Distributor; use Predis\Cluster\Hash\HashGeneratorInterface; /** - * A distributor implements the logic to automatically distribute - * keys among several nodes for client-side sharding. + * Distributors implement the logic to automatically distribute keys among + * several nodes for client-side sharding. * * @author Daniele Alessandri */ -interface DistributionStrategyInterface +interface DistributorInterface { /** * Adds a node to the distributor with an optional weight. diff --git a/lib/Predis/Cluster/Distribution/EmptyRingException.php b/lib/Predis/Cluster/Distributor/EmptyRingException.php similarity index 78% rename from lib/Predis/Cluster/Distribution/EmptyRingException.php rename to lib/Predis/Cluster/Distributor/EmptyRingException.php index ed08ca3e..cb53b383 100644 --- a/lib/Predis/Cluster/Distribution/EmptyRingException.php +++ b/lib/Predis/Cluster/Distributor/EmptyRingException.php @@ -9,13 +9,15 @@ * file that was distributed with this source code. */ -namespace Predis\Cluster\Distribution; +namespace Predis\Cluster\Distributor; + +use Exception; /** * Exception class that identifies empty rings. * * @author Daniele Alessandri */ -class EmptyRingException extends \Exception +class EmptyRingException extends Exception { } diff --git a/lib/Predis/Cluster/Distribution/HashRing.php b/lib/Predis/Cluster/Distributor/HashRing.php similarity index 98% rename from lib/Predis/Cluster/Distribution/HashRing.php rename to lib/Predis/Cluster/Distributor/HashRing.php index 8958929b..00434e24 100644 --- a/lib/Predis/Cluster/Distribution/HashRing.php +++ b/lib/Predis/Cluster/Distributor/HashRing.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Predis\Cluster\Distribution; +namespace Predis\Cluster\Distributor; use Predis\Cluster\Hash\HashGeneratorInterface; @@ -21,7 +21,7 @@ use Predis\Cluster\Hash\HashGeneratorInterface; * @author Daniele Alessandri * @author Lorenzo Castelli */ -class HashRing implements DistributionStrategyInterface, HashGeneratorInterface +class HashRing implements DistributorInterface, HashGeneratorInterface { const DEFAULT_REPLICAS = 128; const DEFAULT_WEIGHT = 100; diff --git a/lib/Predis/Cluster/Distribution/KetamaPureRing.php b/lib/Predis/Cluster/Distributor/KetamaRing.php similarity index 96% rename from lib/Predis/Cluster/Distribution/KetamaPureRing.php rename to lib/Predis/Cluster/Distributor/KetamaRing.php index d68fa959..4e3c10a7 100644 --- a/lib/Predis/Cluster/Distribution/KetamaPureRing.php +++ b/lib/Predis/Cluster/Distributor/KetamaRing.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Predis\Cluster\Distribution; +namespace Predis\Cluster\Distributor; /** * This class implements an hashring-based distributor that uses the same @@ -19,7 +19,7 @@ namespace Predis\Cluster\Distribution; * @author Daniele Alessandri * @author Lorenzo Castelli */ -class KetamaPureRing extends HashRing +class KetamaRing extends HashRing { const DEFAULT_REPLICAS = 160; diff --git a/lib/Predis/Cluster/PredisClusterHashStrategy.php b/lib/Predis/Cluster/PredisStrategy.php similarity index 99% rename from lib/Predis/Cluster/PredisClusterHashStrategy.php rename to lib/Predis/Cluster/PredisStrategy.php index d2e72c35..95119464 100644 --- a/lib/Predis/Cluster/PredisClusterHashStrategy.php +++ b/lib/Predis/Cluster/PredisStrategy.php @@ -21,7 +21,7 @@ use Predis\Command\ScriptedCommand; * * @author Daniele Alessandri */ -class PredisClusterHashStrategy implements CommandHashStrategyInterface +class PredisStrategy implements StrategyInterface { private $commands; private $hashGenerator; diff --git a/lib/Predis/Cluster/RedisClusterHashStrategy.php b/lib/Predis/Cluster/RedisStrategy.php similarity index 98% rename from lib/Predis/Cluster/RedisClusterHashStrategy.php rename to lib/Predis/Cluster/RedisStrategy.php index dfee5cca..c34a4a02 100644 --- a/lib/Predis/Cluster/RedisClusterHashStrategy.php +++ b/lib/Predis/Cluster/RedisStrategy.php @@ -11,7 +11,6 @@ namespace Predis\Cluster; -use Predis\Cluster\Hash\CRC16HashGenerator; use Predis\Command\CommandInterface; use Predis\Command\ScriptedCommand; @@ -21,7 +20,7 @@ use Predis\Command\ScriptedCommand; * * @author Daniele Alessandri */ -class RedisClusterHashStrategy implements CommandHashStrategyInterface +class RedisStrategy implements StrategyInterface { private $commands; private $hashGenerator; @@ -32,7 +31,7 @@ class RedisClusterHashStrategy implements CommandHashStrategyInterface public function __construct() { $this->commands = $this->getDefaultCommands(); - $this->hashGenerator = new CRC16HashGenerator(); + $this->hashGenerator = new Hash\CRC16HashGenerator(); } /** diff --git a/lib/Predis/Cluster/CommandHashStrategyInterface.php b/lib/Predis/Cluster/StrategyInterface.php similarity index 96% rename from lib/Predis/Cluster/CommandHashStrategyInterface.php rename to lib/Predis/Cluster/StrategyInterface.php index bfea0503..cc7ce694 100644 --- a/lib/Predis/Cluster/CommandHashStrategyInterface.php +++ b/lib/Predis/Cluster/StrategyInterface.php @@ -21,7 +21,7 @@ use Predis\Command\CommandInterface; * * @author Daniele Alessandri */ -interface CommandHashStrategyInterface +interface StrategyInterface { /** * Returns the hash for the given command using the specified algorithm, or null diff --git a/lib/Predis/Connection/PredisCluster.php b/lib/Predis/Connection/PredisCluster.php index 1290bce5..b6dd5a22 100644 --- a/lib/Predis/Connection/PredisCluster.php +++ b/lib/Predis/Connection/PredisCluster.php @@ -11,11 +11,11 @@ namespace Predis\Connection; -use Predis\Cluster\CommandHashStrategyInterface; +use Countable; +use IteratorAggregate; use Predis\NotSupportedException; -use Predis\Cluster\PredisClusterHashStrategy; -use Predis\Cluster\Distribution\DistributionStrategyInterface; -use Predis\Cluster\Distribution\HashRing; +use Predis\Cluster; +use Predis\Cluster\Distributor; use Predis\Command\CommandInterface; /** @@ -25,21 +25,21 @@ use Predis\Command\CommandInterface; * @author Daniele Alessandri * @todo Add the ability to remove connections from pool. */ -class PredisCluster implements ClusterConnectionInterface, \IteratorAggregate, \Countable +class PredisCluster implements ClusterConnectionInterface, IteratorAggregate, Countable { private $pool; private $strategy; private $distributor; /** - * @param DistributionStrategyInterface $distributor Distribution strategy used by the cluster. + * @param Distributor\DistributorInterface $distributor Distribution strategy used by the cluster. */ - public function __construct(DistributionStrategyInterface $distributor = null) + public function __construct(Distributor\DistributorInterface $distributor = null) { - $distributor = $distributor ?: new HashRing(); + $distributor = $distributor ?: new Distributor\HashRing(); $this->pool = array(); - $this->strategy = new PredisClusterHashStrategy($distributor->getHashGenerator()); + $this->strategy = new Cluster\PredisStrategy($distributor->getHashGenerator()); $this->distributor = $distributor; } @@ -166,9 +166,9 @@ class PredisCluster implements ClusterConnectionInterface, \IteratorAggregate, \ * Returns the underlying command hash strategy used to hash * commands by their keys. * - * @return CommandHashStrategyInterface + * @return Cluster\StrategyInterface */ - public function getCommandHashStrategy() + public function getClusterStrategy() { return $this->strategy; } diff --git a/lib/Predis/Connection/RedisCluster.php b/lib/Predis/Connection/RedisCluster.php index d81cc580..ff261af6 100644 --- a/lib/Predis/Connection/RedisCluster.php +++ b/lib/Predis/Connection/RedisCluster.php @@ -12,9 +12,8 @@ namespace Predis\Connection; use Predis\ClientException; -use Predis\Cluster\CommandHashStrategyInterface; use Predis\NotSupportedException; -use Predis\Cluster\RedisClusterHashStrategy; +use Predis\Cluster; use Predis\Command\CommandInterface; use Predis\Response; @@ -39,7 +38,7 @@ class RedisCluster implements ClusterConnectionInterface, \IteratorAggregate, \C { $this->pool = array(); $this->slots = array(); - $this->strategy = new RedisClusterHashStrategy(); + $this->strategy = new Cluster\RedisStrategy(); $this->connections = $connections ?: new ConnectionFactory(); } @@ -304,12 +303,11 @@ class RedisCluster implements ClusterConnectionInterface, \IteratorAggregate, \C } /** - * Returns the underlying command hash strategy used to hash - * commands by their keys. + * Returns the underlying hash strategy used to hash commands by their keys. * - * @return CommandHashStrategyInterface + * @return Cluster\StrategyInterface */ - public function getCommandHashStrategy() + public function getClusterStrategy() { return $this->strategy; } diff --git a/tests/PHPUnit/DistributionStrategyTestCase.php b/tests/PHPUnit/DistributorTestCase.php similarity index 74% rename from tests/PHPUnit/DistributionStrategyTestCase.php rename to tests/PHPUnit/DistributorTestCase.php index 722dad74..a8a1a8a6 100644 --- a/tests/PHPUnit/DistributionStrategyTestCase.php +++ b/tests/PHPUnit/DistributorTestCase.php @@ -9,30 +9,30 @@ * file that was distributed with this source code. */ -namespace Predis\Cluster\Distribution; +namespace Predis\Cluster\Distributor; use PHPUnit_Framework_TestCase as StandardTestCase; /** * */ -abstract class DistributionStrategyTestCase extends StandardTestCase +abstract class DistributorTestCase extends StandardTestCase { /** * Returns a new instance of the tested distributor. * - * @return Predis\Cluster\Distribution\DistributionStrategyInterface + * @return Predis\Cluster\Distributor\DistributorInterface */ protected abstract function getDistributorInstance(); /** * Returns a list of nodes from the hashring. * - * @param DistributionStrategyInterface $ring Hashring instance. + * @param DistributorInterface $ring Hashring instance. * @param int $iterations Number of nodes to fetch. * @return array Nodes from the hashring. */ - protected function getNodes(DistributionStrategyInterface $ring, $iterations = 10) + protected function getNodes(DistributorInterface $ring, $iterations = 10) { $nodes = array(); @@ -49,7 +49,7 @@ abstract class DistributionStrategyTestCase extends StandardTestCase */ public function testEmptyRingThrowsException() { - $this->setExpectedException('Predis\Cluster\Distribution\EmptyRingException'); + $this->setExpectedException('Predis\Cluster\Distributor\EmptyRingException'); $ring = $this->getDistributorInstance(); $ring->get('nodekey'); diff --git a/tests/Predis/Cluster/Distribution/EmptyRingExceptionTest.php b/tests/Predis/Cluster/Distributor/EmptyRingExceptionTest.php similarity index 80% rename from tests/Predis/Cluster/Distribution/EmptyRingExceptionTest.php rename to tests/Predis/Cluster/Distributor/EmptyRingExceptionTest.php index cde51a79..ccc0b6a2 100644 --- a/tests/Predis/Cluster/Distribution/EmptyRingExceptionTest.php +++ b/tests/Predis/Cluster/Distributor/EmptyRingExceptionTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Predis\Cluster\Distribution; +namespace Predis\Cluster\Distributor; use PHPUnit_Framework_TestCase as StandardTestCase; @@ -24,7 +24,7 @@ class EmptyRingExceptionTest extends StandardTestCase public function testExceptionMessage() { $message = 'Empty Ring'; - $this->setExpectedException('Predis\Cluster\Distribution\EmptyRingException', $message); + $this->setExpectedException('Predis\Cluster\Distributor\EmptyRingException', $message); throw new EmptyRingException($message); } diff --git a/tests/Predis/Cluster/Distribution/HashRingTest.php b/tests/Predis/Cluster/Distributor/HashRingTest.php similarity index 96% rename from tests/Predis/Cluster/Distribution/HashRingTest.php rename to tests/Predis/Cluster/Distributor/HashRingTest.php index e618ea00..7a4f71dc 100644 --- a/tests/Predis/Cluster/Distribution/HashRingTest.php +++ b/tests/Predis/Cluster/Distributor/HashRingTest.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Predis\Cluster\Distribution; +namespace Predis\Cluster\Distributor; /** * @todo To be improved. */ -class HashRingTest extends DistributionStrategyTestCase +class HashRingTest extends DistributorTestCase { /** * {@inheritdoc} @@ -131,7 +131,7 @@ class HashRingTest extends DistributionStrategyTestCase } /** - * @todo This tests should be moved in Predis\Cluster\Distribution\DistributionStrategyTestCase + * @todo This tests should be moved in Predis\Cluster\Distributor\DistributorTestCase * @group disconnected */ public function testCallbackToGetNodeHash() diff --git a/tests/Predis/Cluster/Distribution/KetamaPureRingTest.php b/tests/Predis/Cluster/Distributor/KetamaRingTest.php similarity index 94% rename from tests/Predis/Cluster/Distribution/KetamaPureRingTest.php rename to tests/Predis/Cluster/Distributor/KetamaRingTest.php index b5c3145e..def2b670 100644 --- a/tests/Predis/Cluster/Distribution/KetamaPureRingTest.php +++ b/tests/Predis/Cluster/Distributor/KetamaRingTest.php @@ -9,19 +9,19 @@ * file that was distributed with this source code. */ -namespace Predis\Cluster\Distribution; +namespace Predis\Cluster\Distributor; /** * @todo To be improved. */ -class KetamaPureRingTest extends DistributionStrategyTestCase +class KetamaRingTest extends DistributorTestCase { /** * {@inheritdoc} */ public function getDistributorInstance() { - return new KetamaPureRing(); + return new KetamaRing(); } /** @@ -132,7 +132,7 @@ class KetamaPureRingTest extends DistributionStrategyTestCase } /** - * @todo This tests should be moved in Predis\Cluster\Distribution\DistributionStrategyTestCase + * @todo This tests should be moved in Predis\Cluster\Distributor\DistributorTestCase * @group disconnected */ public function testCallbackToGetNodeHash() @@ -145,7 +145,7 @@ class KetamaPureRingTest extends DistributionStrategyTestCase ->with($node) ->will($this->returnValue($node)); - $ring = new KetamaPureRing($callable); + $ring = new KetamaRing($callable); $ring->add($node); $this->getNodes($ring); diff --git a/tests/Predis/Cluster/PredisClusterHashStrategyTest.php b/tests/Predis/Cluster/PredisStrategyTest.php similarity index 93% rename from tests/Predis/Cluster/PredisClusterHashStrategyTest.php rename to tests/Predis/Cluster/PredisStrategyTest.php index 0e57f693..8609869d 100644 --- a/tests/Predis/Cluster/PredisClusterHashStrategyTest.php +++ b/tests/Predis/Cluster/PredisStrategyTest.php @@ -13,13 +13,12 @@ namespace Predis\Cluster; use PHPUnit_Framework_TestCase as StandardTestCase; -use Predis\Cluster\Distribution\HashRing; use Predis\Profile\ServerProfile; /** * */ -class PredisClusterHashStrategyTest extends StandardTestCase +class PredisStrategyTest extends StandardTestCase { /** * @group disconnected @@ -29,7 +28,7 @@ class PredisClusterHashStrategyTest extends StandardTestCase // NOTE: 32 and 64 bits PHP runtimes can produce different hash values. $expected = PHP_INT_SIZE == 4 ? -1938594527 : 2356372769; - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $this->assertSame($expected, $strategy->getKeyHash('{foo}')); $this->assertSame($expected, $strategy->getKeyHash('{foo}:bar')); @@ -45,7 +44,7 @@ class PredisClusterHashStrategyTest extends StandardTestCase */ public function testSupportedCommands() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $this->assertSame($this->getExpectedCommands(), $strategy->getSupportedCommands()); } @@ -55,7 +54,7 @@ class PredisClusterHashStrategyTest extends StandardTestCase */ public function testReturnsNullOnUnsupportedCommand() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $command = ServerProfile::getDevelopment()->createCommand('ping'); $this->assertNull($strategy->getHash($command)); @@ -66,7 +65,7 @@ class PredisClusterHashStrategyTest extends StandardTestCase */ public function testFirstKeyCommands() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $profile = ServerProfile::getDevelopment(); $arguments = array('key'); @@ -81,7 +80,7 @@ class PredisClusterHashStrategyTest extends StandardTestCase */ public function testAllKeysCommands() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $profile = ServerProfile::getDevelopment(); $arguments = array('{key}:1', '{key}:2', '{key}:3', '{key}:4'); @@ -96,7 +95,7 @@ class PredisClusterHashStrategyTest extends StandardTestCase */ public function testInterleavedKeysCommands() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $profile = ServerProfile::getDevelopment(); $arguments = array('{key}:1', 'value1', '{key}:2', 'value2'); @@ -111,7 +110,7 @@ class PredisClusterHashStrategyTest extends StandardTestCase */ public function testKeysForBlockingListCommands() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $profile = ServerProfile::getDevelopment(); $arguments = array('{key}:1', '{key}:2', 10); @@ -126,7 +125,7 @@ class PredisClusterHashStrategyTest extends StandardTestCase */ public function testKeysForZsetAggregationCommands() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $profile = ServerProfile::getDevelopment(); $arguments = array('{key}:destination', 2, '{key}:1', '{key}:1', array('aggregate' => 'SUM')); @@ -141,7 +140,7 @@ class PredisClusterHashStrategyTest extends StandardTestCase */ public function testKeysForBitOpCommand() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $profile = ServerProfile::getDevelopment(); $arguments = array('AND', '{key}:destination', '{key}:src:1', '{key}:src:2'); @@ -156,7 +155,7 @@ class PredisClusterHashStrategyTest extends StandardTestCase */ public function testKeysForScriptCommand() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $profile = ServerProfile::getDevelopment(); $arguments = array('%SCRIPT%', 2, '{key}:1', '{key}:2', 'value1', 'value2'); @@ -171,7 +170,7 @@ class PredisClusterHashStrategyTest extends StandardTestCase */ public function testKeysForScriptedCommand() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $arguments = array('{key}:1', '{key}:2', 'value1', 'value2'); $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); @@ -191,7 +190,7 @@ class PredisClusterHashStrategyTest extends StandardTestCase */ public function testUnsettingCommandHandler() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $profile = ServerProfile::getDevelopment(); $strategy->setCommandHandler('set'); @@ -209,7 +208,7 @@ class PredisClusterHashStrategyTest extends StandardTestCase */ public function testSettingCustomCommandHandler() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $profile = ServerProfile::getDevelopment(); $callable = $this->getMock('stdClass', array('__invoke')); @@ -229,15 +228,15 @@ class PredisClusterHashStrategyTest extends StandardTestCase // ******************************************************************** // /** - * Creates the default hash strategy object. + * Creates the default cluster strategy object. * - * @return CommandHashStrategyInterface + * @return StrategyInterface */ - protected function getHashStrategy() + protected function getClusterStrategy() { - $distributor = new HashRing(); + $distributor = new Distributor\HashRing(); $hashGenerator = $distributor->getHashGenerator(); - $strategy = new PredisClusterHashStrategy($hashGenerator); + $strategy = new PredisStrategy($hashGenerator); return $strategy; } diff --git a/tests/Predis/Cluster/RedisClusterHashStrategyTest.php b/tests/Predis/Cluster/RedisStrategyTest.php similarity index 93% rename from tests/Predis/Cluster/RedisClusterHashStrategyTest.php rename to tests/Predis/Cluster/RedisStrategyTest.php index 01d820aa..2d1cca01 100644 --- a/tests/Predis/Cluster/RedisClusterHashStrategyTest.php +++ b/tests/Predis/Cluster/RedisStrategyTest.php @@ -18,14 +18,14 @@ use Predis\Profile\ServerProfile; /** * */ -class RedisClusterHashStrategyTest extends StandardTestCase +class RedisStrategyTest extends StandardTestCase { /** * @group disconnected */ public function testDoesNotSupportKeyTags() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $this->assertSame(35910, $strategy->getKeyHash('{foo}')); $this->assertSame(60032, $strategy->getKeyHash('{foo}:bar')); @@ -38,7 +38,7 @@ class RedisClusterHashStrategyTest extends StandardTestCase */ public function testSupportedCommands() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $this->assertSame($this->getExpectedCommands(), $strategy->getSupportedCommands()); } @@ -48,7 +48,7 @@ class RedisClusterHashStrategyTest extends StandardTestCase */ public function testReturnsNullOnUnsupportedCommand() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $command = ServerProfile::getDevelopment()->createCommand('ping'); $this->assertNull($strategy->getHash($command)); @@ -59,7 +59,7 @@ class RedisClusterHashStrategyTest extends StandardTestCase */ public function testFirstKeyCommands() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $profile = ServerProfile::getDevelopment(); $arguments = array('key'); @@ -74,7 +74,7 @@ class RedisClusterHashStrategyTest extends StandardTestCase */ public function testAllKeysCommandsWithOneKey() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $profile = ServerProfile::getDevelopment(); $arguments = array('key'); @@ -89,7 +89,7 @@ class RedisClusterHashStrategyTest extends StandardTestCase */ public function testAllKeysCommandsWithMoreKeys() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $profile = ServerProfile::getDevelopment(); $arguments = array('key1', 'key2'); @@ -104,7 +104,7 @@ class RedisClusterHashStrategyTest extends StandardTestCase */ public function testInterleavedKeysCommandsWithOneKey() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $profile = ServerProfile::getDevelopment(); $arguments = array('key:1', 'value1'); @@ -119,7 +119,7 @@ class RedisClusterHashStrategyTest extends StandardTestCase */ public function testInterleavedKeysCommandsWithMoreKeys() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $profile = ServerProfile::getDevelopment(); $arguments = array('key:1', 'value1', 'key:2', 'value2'); @@ -134,7 +134,7 @@ class RedisClusterHashStrategyTest extends StandardTestCase */ public function testKeysForBlockingListCommandsWithOneKey() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $profile = ServerProfile::getDevelopment(); $arguments = array('key:1', 10); @@ -149,7 +149,7 @@ class RedisClusterHashStrategyTest extends StandardTestCase */ public function testKeysForBlockingListCommandsWithMoreKeys() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $profile = ServerProfile::getDevelopment(); $arguments = array('key:1', 'key:2', 10); @@ -164,7 +164,7 @@ class RedisClusterHashStrategyTest extends StandardTestCase */ public function testKeysForScriptCommand() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $profile = ServerProfile::getDevelopment(); $arguments = array('%SCRIPT%', 1, 'key:1', 'value1'); @@ -179,7 +179,7 @@ class RedisClusterHashStrategyTest extends StandardTestCase */ public function testKeysForScriptedCommand() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $arguments = array('key:1', 'value1'); $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); @@ -199,7 +199,7 @@ class RedisClusterHashStrategyTest extends StandardTestCase */ public function testUnsettingCommandHandler() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $profile = ServerProfile::getDevelopment(); $strategy->setCommandHandler('set'); @@ -217,7 +217,7 @@ class RedisClusterHashStrategyTest extends StandardTestCase */ public function testSettingCustomCommandHandler() { - $strategy = $this->getHashStrategy(); + $strategy = $this->getClusterStrategy(); $profile = ServerProfile::getDevelopment(); $callable = $this->getMock('stdClass', array('__invoke')); @@ -237,13 +237,13 @@ class RedisClusterHashStrategyTest extends StandardTestCase // ******************************************************************** // /** - * Creates the default hash strategy object. + * Creates the default cluster strategy object. * - * @return CommandHashStrategyInterface + * @return StrategyInterface */ - protected function getHashStrategy() + protected function getClusterStrategy() { - $strategy = new RedisClusterHashStrategy(); + $strategy = new RedisStrategy(); return $strategy; } diff --git a/tests/Predis/Connection/PredisClusterTest.php b/tests/Predis/Connection/PredisClusterTest.php index f88eaedb..2ea8d446 100644 --- a/tests/Predis/Connection/PredisClusterTest.php +++ b/tests/Predis/Connection/PredisClusterTest.php @@ -26,7 +26,7 @@ class PredisClusterTest extends StandardTestCase public function testExposesCommandHashStrategy() { $cluster = new PredisCluster(); - $this->assertInstanceOf('Predis\Cluster\PredisClusterHashStrategy', $cluster->getCommandHashStrategy()); + $this->assertInstanceOf('Predis\Cluster\PredisStrategy', $cluster->getClusterStrategy()); } /** diff --git a/tests/Predis/Connection/RedisClusterTest.php b/tests/Predis/Connection/RedisClusterTest.php index c0e72fdc..df74b9c1 100644 --- a/tests/Predis/Connection/RedisClusterTest.php +++ b/tests/Predis/Connection/RedisClusterTest.php @@ -27,7 +27,7 @@ class RedisClusterTest extends StandardTestCase public function testExposesCommandHashStrategy() { $cluster = new RedisCluster(); - $this->assertInstanceOf('Predis\Cluster\RedisClusterHashStrategy', $cluster->getCommandHashStrategy()); + $this->assertInstanceOf('Predis\Cluster\RedisStrategy', $cluster->getClusterStrategy()); } /** diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 43c600ea..7bcf5b22 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -15,4 +15,4 @@ require __DIR__.'/PHPUnit/ArrayHasSameValuesConstraint.php'; require __DIR__.'/PHPUnit/CommandTestCase.php'; require __DIR__.'/PHPUnit/ConnectionTestCase.php'; require __DIR__.'/PHPUnit/ServerVersionTestCase.php'; -require __DIR__.'/PHPUnit/DistributionStrategyTestCase.php'; +require __DIR__.'/PHPUnit/DistributorTestCase.php';