From 5ad00774e1b2c1366e79a19e58f6d428f1563448 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Thu, 7 Nov 2013 11:10:22 +0100 Subject: [PATCH] Rename for the last time all the iterator classes. We are experimenting with a new approach at naming classes using less redundant names by leveraging the containing namespace. The PHP "use" directive is not limited to class names but can be used to import the whole namespace, which means you can do something like this: use Predis\Collection\Iterator; // ... foreach (new Iterator\Keyspace($client) as $key) { // ... } Alternatively you can always rely on "use ... as ..." to import one of the classes by giving it a more meaningful name in the context of the root namespace: use Predis\Collection\Iterator\Keyspace as KeyspaceIterator; // ... foreach (new KeyspaceIterator($client) as $key) { // ... } In this specific case we chose to apply the -Key postfix to classes iterating Redis keys to be more explicit about the fact that those iterators does not work on local in-memory collections, but fetch items from a key stored on a remote Redis server. --- examples/RedisCollectionsIterators.php | 21 ++++++-------- ...onIterator.php => CursorBasedIterator.php} | 2 +- .../{HashIterator.php => HashKey.php} | 2 +- .../{KeyspaceIterator.php => Keyspace.php} | 2 +- .../Iterator/{SetIterator.php => SetKey.php} | 2 +- ...SortedSetIterator.php => SortedSetKey.php} | 2 +- .../{HashIteratorTest.php => HashKeyTest.php} | 28 +++++++++---------- ...spaceIteratorTest.php => KeyspaceTest.php} | 28 +++++++++---------- .../{SetIteratorTest.php => SetKeyTest.php} | 28 +++++++++---------- ...tIteratorTest.php => SortedSetKeyTest.php} | 28 +++++++++---------- 10 files changed, 70 insertions(+), 73 deletions(-) rename lib/Predis/Collection/Iterator/{RedisCollectionIterator.php => CursorBasedIterator.php} (98%) rename lib/Predis/Collection/Iterator/{HashIterator.php => HashKey.php} (96%) rename lib/Predis/Collection/Iterator/{KeyspaceIterator.php => Keyspace.php} (94%) rename lib/Predis/Collection/Iterator/{SetIterator.php => SetKey.php} (95%) rename lib/Predis/Collection/Iterator/{SortedSetIterator.php => SortedSetKey.php} (95%) rename tests/Predis/Collection/Iterator/{HashIteratorTest.php => HashKeyTest.php} (94%) rename tests/Predis/Collection/Iterator/{KeyspaceIteratorTest.php => KeyspaceTest.php} (94%) rename tests/Predis/Collection/Iterator/{SetIteratorTest.php => SetKeyTest.php} (94%) rename tests/Predis/Collection/Iterator/{SortedSetIteratorTest.php => SortedSetKeyTest.php} (94%) diff --git a/examples/RedisCollectionsIterators.php b/examples/RedisCollectionsIterators.php index f7b00c29..e333c266 100644 --- a/examples/RedisCollectionsIterators.php +++ b/examples/RedisCollectionsIterators.php @@ -11,10 +11,7 @@ require 'SharedConfigurations.php'; -use Predis\Collection\Iterator\KeyspaceIterator; -use Predis\Collection\Iterator\SetIterator; -use Predis\Collection\Iterator\SortedSetIterator; -use Predis\Collection\Iterator\HashIterator; +use Predis\Collection\Iterator; // Redis 2.8 features new commands allowing clients to incrementally // iterate over collections without blocking the server like it happens @@ -40,9 +37,9 @@ for ($i = 0; $i < 5; $i++) { $client->hset('predis:hash', "field:$i", "value:$i"); } -// === KeyspaceIterator based on SCAN === +// === Keyspace iterator based on SCAN === echo 'Scan the keyspace matching only our prefixed keys:' . PHP_EOL; -foreach (new KeyspaceIterator($client, 'predis:*') as $key) { +foreach (new Iterator\Keyspace($client, 'predis:*') as $key) { echo " - $key" . PHP_EOL; } @@ -53,9 +50,9 @@ Scan the keyspace matching only our prefixed keys: - predis:hash */ -// === SetIterator class based on SSCAN === +// === Set iterator based on SSCAN === echo 'Scan members of `predis:set`:' . PHP_EOL; -foreach (new SetIterator($client, 'predis:set') as $member) { +foreach (new Iterator\SetKey($client, 'predis:set') as $member) { echo " - $member" . PHP_EOL; } @@ -68,9 +65,9 @@ Scan members of `predis:set`: - member:2 */ -// === SortedSetIterator class based on ZSCAN === +// === Sorted set iterator based on ZSCAN === echo 'Scan members and ranks of `predis:zset`:' . PHP_EOL; -foreach (new SortedSetIterator($client, 'predis:zset') as $member => $rank) { +foreach (new Iterator\SortedSetKey($client, 'predis:zset') as $member => $rank) { echo " - $member [rank: $rank]" . PHP_EOL; } @@ -83,9 +80,9 @@ Scan members and ranks of `predis:zset`: - member:0 [rank: 0] */ -// === HashIterator class based on HSCAN === +// === Hash iterator based on HSCAN === echo 'Scan fields and values of `predis:hash`:' . PHP_EOL; -foreach (new HashIterator($client, 'predis:hash') as $field => $value) { +foreach (new Iterator\HashKey($client, 'predis:hash') as $field => $value) { echo " - $field => $value" . PHP_EOL; } diff --git a/lib/Predis/Collection/Iterator/RedisCollectionIterator.php b/lib/Predis/Collection/Iterator/CursorBasedIterator.php similarity index 98% rename from lib/Predis/Collection/Iterator/RedisCollectionIterator.php rename to lib/Predis/Collection/Iterator/CursorBasedIterator.php index 83075e40..adfcd909 100644 --- a/lib/Predis/Collection/Iterator/RedisCollectionIterator.php +++ b/lib/Predis/Collection/Iterator/CursorBasedIterator.php @@ -25,7 +25,7 @@ use Predis\NotSupportedException; * * @author Daniele Alessandri */ -abstract class RedisCollectionIterator implements Iterator +abstract class CursorBasedIterator implements Iterator { protected $client; protected $match; diff --git a/lib/Predis/Collection/Iterator/HashIterator.php b/lib/Predis/Collection/Iterator/HashKey.php similarity index 96% rename from lib/Predis/Collection/Iterator/HashIterator.php rename to lib/Predis/Collection/Iterator/HashKey.php index 80c8ae50..6fa3d9b9 100644 --- a/lib/Predis/Collection/Iterator/HashIterator.php +++ b/lib/Predis/Collection/Iterator/HashKey.php @@ -21,7 +21,7 @@ use Predis\ClientInterface; * @author Daniele Alessandri * @link http://redis.io/commands/scan */ -class HashIterator extends RedisCollectionIterator +class HashKey extends CursorBasedIterator { protected $key; diff --git a/lib/Predis/Collection/Iterator/KeyspaceIterator.php b/lib/Predis/Collection/Iterator/Keyspace.php similarity index 94% rename from lib/Predis/Collection/Iterator/KeyspaceIterator.php rename to lib/Predis/Collection/Iterator/Keyspace.php index dd5c9934..8000063f 100644 --- a/lib/Predis/Collection/Iterator/KeyspaceIterator.php +++ b/lib/Predis/Collection/Iterator/Keyspace.php @@ -21,7 +21,7 @@ use Predis\ClientInterface; * @author Daniele Alessandri * @link http://redis.io/commands/scan */ -class KeyspaceIterator extends RedisCollectionIterator +class Keyspace extends CursorBasedIterator { /** * {@inheritdoc} diff --git a/lib/Predis/Collection/Iterator/SetIterator.php b/lib/Predis/Collection/Iterator/SetKey.php similarity index 95% rename from lib/Predis/Collection/Iterator/SetIterator.php rename to lib/Predis/Collection/Iterator/SetKey.php index 5b33eb3b..224c24f6 100644 --- a/lib/Predis/Collection/Iterator/SetIterator.php +++ b/lib/Predis/Collection/Iterator/SetKey.php @@ -21,7 +21,7 @@ use Predis\ClientInterface; * @author Daniele Alessandri * @link http://redis.io/commands/scan */ -class SetIterator extends RedisCollectionIterator +class SetKey extends CursorBasedIterator { protected $key; diff --git a/lib/Predis/Collection/Iterator/SortedSetIterator.php b/lib/Predis/Collection/Iterator/SortedSetKey.php similarity index 95% rename from lib/Predis/Collection/Iterator/SortedSetIterator.php rename to lib/Predis/Collection/Iterator/SortedSetKey.php index fc31d7a7..a774813b 100644 --- a/lib/Predis/Collection/Iterator/SortedSetIterator.php +++ b/lib/Predis/Collection/Iterator/SortedSetKey.php @@ -21,7 +21,7 @@ use Predis\ClientInterface; * @author Daniele Alessandri * @link http://redis.io/commands/scan */ -class SortedSetIterator extends RedisCollectionIterator +class SortedSetKey extends CursorBasedIterator { protected $key; diff --git a/tests/Predis/Collection/Iterator/HashIteratorTest.php b/tests/Predis/Collection/Iterator/HashKeyTest.php similarity index 94% rename from tests/Predis/Collection/Iterator/HashIteratorTest.php rename to tests/Predis/Collection/Iterator/HashKeyTest.php index 52f8850a..4fc11493 100644 --- a/tests/Predis/Collection/Iterator/HashIteratorTest.php +++ b/tests/Predis/Collection/Iterator/HashKeyTest.php @@ -19,7 +19,7 @@ use Predis\Profile\ServerProfile; /** * @group realm-iterators */ -class HashIteratorTest extends StandardTestCase +class HashKeyTest extends StandardTestCase { /** * @group disconnected @@ -34,7 +34,7 @@ class HashIteratorTest extends StandardTestCase ->method('getProfile') ->will($this->returnValue(ServerProfile::get('2.0'))); - $iterator = new HashIterator($client, 'key:hash'); + $iterator = new HashKey($client, 'key:hash'); } /** @@ -52,7 +52,7 @@ class HashIteratorTest extends StandardTestCase ->with('key:hash', 0, array()) ->will($this->returnValue(array(0, array()))); - $iterator = new HashIterator($client, 'key:hash'); + $iterator = new HashKey($client, 'key:hash'); $iterator->rewind(); $this->assertFalse($iterator->valid()); @@ -75,7 +75,7 @@ class HashIteratorTest extends StandardTestCase 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', 'field:3rd' => 'value:3rd', )))); - $iterator = new HashIterator($client, 'key:hash'); + $iterator = new HashKey($client, 'key:hash'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -119,7 +119,7 @@ class HashIteratorTest extends StandardTestCase 'field:3rd' => 'value:3rd', )))); - $iterator = new HashIterator($client, 'key:hash'); + $iterator = new HashKey($client, 'key:hash'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -161,7 +161,7 @@ class HashIteratorTest extends StandardTestCase 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', )))); - $iterator = new HashIterator($client, 'key:hash'); + $iterator = new HashKey($client, 'key:hash'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -204,7 +204,7 @@ class HashIteratorTest extends StandardTestCase 'field:3rd' => 'value:3rd', )))); - $iterator = new HashIterator($client, 'key:hash'); + $iterator = new HashKey($client, 'key:hash'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -242,7 +242,7 @@ class HashIteratorTest extends StandardTestCase 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', )))); - $iterator = new HashIterator($client, 'key:hash', 'field:*'); + $iterator = new HashKey($client, 'key:hash', 'field:*'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -281,7 +281,7 @@ class HashIteratorTest extends StandardTestCase 'field:2nd' => 'value:2nd', )))); - $iterator = new HashIterator($client, 'key:hash', 'field:*'); + $iterator = new HashKey($client, 'key:hash', 'field:*'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -314,7 +314,7 @@ class HashIteratorTest extends StandardTestCase 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', )))); - $iterator = new HashIterator($client, 'key:hash', null, 2); + $iterator = new HashKey($client, 'key:hash', null, 2); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -353,7 +353,7 @@ class HashIteratorTest extends StandardTestCase 'field:2nd' => 'value:2nd', )))); - $iterator = new HashIterator($client, 'key:hash', null, 1); + $iterator = new HashKey($client, 'key:hash', null, 1); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -386,7 +386,7 @@ class HashIteratorTest extends StandardTestCase 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', )))); - $iterator = new HashIterator($client, 'key:hash', 'field:*', 2); + $iterator = new HashKey($client, 'key:hash', 'field:*', 2); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -425,7 +425,7 @@ class HashIteratorTest extends StandardTestCase 'field:2nd' => 'value:2nd', )))); - $iterator = new HashIterator($client, 'key:hash', 'field:*', 1); + $iterator = new HashKey($client, 'key:hash', 'field:*', 1); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -458,7 +458,7 @@ class HashIteratorTest extends StandardTestCase 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', )))); - $iterator = new HashIterator($client, 'key:hash'); + $iterator = new HashKey($client, 'key:hash'); $iterator->rewind(); $this->assertTrue($iterator->valid()); diff --git a/tests/Predis/Collection/Iterator/KeyspaceIteratorTest.php b/tests/Predis/Collection/Iterator/KeyspaceTest.php similarity index 94% rename from tests/Predis/Collection/Iterator/KeyspaceIteratorTest.php rename to tests/Predis/Collection/Iterator/KeyspaceTest.php index fdf86fc5..28ad9390 100644 --- a/tests/Predis/Collection/Iterator/KeyspaceIteratorTest.php +++ b/tests/Predis/Collection/Iterator/KeyspaceTest.php @@ -19,7 +19,7 @@ use Predis\Profile\ServerProfile; /** * @group realm-iterators */ -class KeyspaceIteratorTest extends StandardTestCase +class KeyspaceTest extends StandardTestCase { /** * @group disconnected @@ -34,7 +34,7 @@ class KeyspaceIteratorTest extends StandardTestCase ->method('getProfile') ->will($this->returnValue(ServerProfile::get('2.0'))); - $iterator = new KeyspaceIterator($client); + $iterator = new Keyspace($client); } /** @@ -52,7 +52,7 @@ class KeyspaceIteratorTest extends StandardTestCase ->with(0, array()) ->will($this->returnValue(array(0, array()))); - $iterator = new KeyspaceIterator($client); + $iterator = new Keyspace($client); $iterator->rewind(); $this->assertFalse($iterator->valid()); @@ -73,7 +73,7 @@ class KeyspaceIteratorTest extends StandardTestCase ->with(0, array()) ->will($this->returnValue(array(0, array('key:1st', 'key:2nd', 'key:3rd')))); - $iterator = new KeyspaceIterator($client); + $iterator = new Keyspace($client); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -113,7 +113,7 @@ class KeyspaceIteratorTest extends StandardTestCase ->with(2, array()) ->will($this->returnValue(array(0, array('key:3rd')))); - $iterator = new KeyspaceIterator($client); + $iterator = new Keyspace($client); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -153,7 +153,7 @@ class KeyspaceIteratorTest extends StandardTestCase ->with(4, array()) ->will($this->returnValue(array(0, array('key:1st', 'key:2nd')))); - $iterator = new KeyspaceIterator($client); + $iterator = new Keyspace($client); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -192,7 +192,7 @@ class KeyspaceIteratorTest extends StandardTestCase ->with(5, array()) ->will($this->returnValue(array(0, array('key:3rd')))); - $iterator = new KeyspaceIterator($client); + $iterator = new Keyspace($client); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -228,7 +228,7 @@ class KeyspaceIteratorTest extends StandardTestCase ->with(0, array('MATCH' => 'key:*')) ->will($this->returnValue(array(0, array('key:1st', 'key:2nd')))); - $iterator = new KeyspaceIterator($client, 'key:*'); + $iterator = new Keyspace($client, 'key:*'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -263,7 +263,7 @@ class KeyspaceIteratorTest extends StandardTestCase ->with(1, array('MATCH' => 'key:*')) ->will($this->returnValue(array(0, array('key:2nd')))); - $iterator = new KeyspaceIterator($client, 'key:*'); + $iterator = new Keyspace($client, 'key:*'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -294,7 +294,7 @@ class KeyspaceIteratorTest extends StandardTestCase ->with(0, array('COUNT' => 2)) ->will($this->returnValue(array(0, array('key:1st', 'key:2nd')))); - $iterator = new KeyspaceIterator($client, null, 2); + $iterator = new Keyspace($client, null, 2); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -329,7 +329,7 @@ class KeyspaceIteratorTest extends StandardTestCase ->with(1, array('COUNT' => 1)) ->will($this->returnValue(array(0, array('key:2nd')))); - $iterator = new KeyspaceIterator($client, null, 1); + $iterator = new Keyspace($client, null, 1); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -360,7 +360,7 @@ class KeyspaceIteratorTest extends StandardTestCase ->with(0, array('MATCH' => 'key:*', 'COUNT' => 2)) ->will($this->returnValue(array(0, array('key:1st', 'key:2nd')))); - $iterator = new KeyspaceIterator($client, 'key:*', 2); + $iterator = new Keyspace($client, 'key:*', 2); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -395,7 +395,7 @@ class KeyspaceIteratorTest extends StandardTestCase ->with(1, array('MATCH' => 'key:*', 'COUNT' => 1)) ->will($this->returnValue(array(0, array('key:2nd')))); - $iterator = new KeyspaceIterator($client, 'key:*', 1); + $iterator = new Keyspace($client, 'key:*', 1); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -426,7 +426,7 @@ class KeyspaceIteratorTest extends StandardTestCase ->with(0, array()) ->will($this->returnValue(array(0, array('key:1st', 'key:2nd')))); - $iterator = new KeyspaceIterator($client); + $iterator = new Keyspace($client); $iterator->rewind(); $this->assertTrue($iterator->valid()); diff --git a/tests/Predis/Collection/Iterator/SetIteratorTest.php b/tests/Predis/Collection/Iterator/SetKeyTest.php similarity index 94% rename from tests/Predis/Collection/Iterator/SetIteratorTest.php rename to tests/Predis/Collection/Iterator/SetKeyTest.php index a2441f26..ba2d7776 100644 --- a/tests/Predis/Collection/Iterator/SetIteratorTest.php +++ b/tests/Predis/Collection/Iterator/SetKeyTest.php @@ -19,7 +19,7 @@ use Predis\Profile\ServerProfile; /** * @group realm-iterators */ -class SetIteratorTest extends StandardTestCase +class SetKeyTest extends StandardTestCase { /** * @group disconnected @@ -34,7 +34,7 @@ class SetIteratorTest extends StandardTestCase ->method('getProfile') ->will($this->returnValue(ServerProfile::get('2.0'))); - $iterator = new SetIterator($client, 'key:set'); + $iterator = new SetKey($client, 'key:set'); } /** @@ -52,7 +52,7 @@ class SetIteratorTest extends StandardTestCase ->with('key:set', 0, array()) ->will($this->returnValue(array(0, array()))); - $iterator = new SetIterator($client, 'key:set'); + $iterator = new SetKey($client, 'key:set'); $iterator->rewind(); $this->assertFalse($iterator->valid()); @@ -73,7 +73,7 @@ class SetIteratorTest extends StandardTestCase ->with('key:set', 0, array()) ->will($this->returnValue(array(0, array('member:1st', 'member:2nd', 'member:3rd')))); - $iterator = new SetIterator($client, 'key:set'); + $iterator = new SetKey($client, 'key:set'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -113,7 +113,7 @@ class SetIteratorTest extends StandardTestCase ->with('key:set', 2, array()) ->will($this->returnValue(array(0, array('member:3rd')))); - $iterator = new SetIterator($client, 'key:set'); + $iterator = new SetKey($client, 'key:set'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -153,7 +153,7 @@ class SetIteratorTest extends StandardTestCase ->with('key:set', 4, array()) ->will($this->returnValue(array(0, array('member:1st', 'member:2nd')))); - $iterator = new SetIterator($client, 'key:set'); + $iterator = new SetKey($client, 'key:set'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -192,7 +192,7 @@ class SetIteratorTest extends StandardTestCase ->with('key:set', 5, array()) ->will($this->returnValue(array(0, array('member:3rd')))); - $iterator = new SetIterator($client, 'key:set'); + $iterator = new SetKey($client, 'key:set'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -228,7 +228,7 @@ class SetIteratorTest extends StandardTestCase ->with('key:set', 0, array('MATCH' => 'member:*')) ->will($this->returnValue(array(0, array('member:1st', 'member:2nd')))); - $iterator = new SetIterator($client, 'key:set', 'member:*'); + $iterator = new SetKey($client, 'key:set', 'member:*'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -263,7 +263,7 @@ class SetIteratorTest extends StandardTestCase ->with('key:set', 1, array('MATCH' => 'member:*')) ->will($this->returnValue(array(0, array('member:2nd')))); - $iterator = new SetIterator($client, 'key:set', 'member:*'); + $iterator = new SetKey($client, 'key:set', 'member:*'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -294,7 +294,7 @@ class SetIteratorTest extends StandardTestCase ->with('key:set', 0, array('COUNT' => 2)) ->will($this->returnValue(array(0, array('member:1st', 'member:2nd')))); - $iterator = new SetIterator($client, 'key:set', null, 2); + $iterator = new SetKey($client, 'key:set', null, 2); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -329,7 +329,7 @@ class SetIteratorTest extends StandardTestCase ->with('key:set', 1, array('COUNT' => 1)) ->will($this->returnValue(array(0, array('member:2nd')))); - $iterator = new SetIterator($client, 'key:set', null, 1); + $iterator = new SetKey($client, 'key:set', null, 1); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -360,7 +360,7 @@ class SetIteratorTest extends StandardTestCase ->with('key:set', 0, array('MATCH' => 'member:*', 'COUNT' => 2)) ->will($this->returnValue(array(0, array('member:1st', 'member:2nd')))); - $iterator = new SetIterator($client, 'key:set', 'member:*', 2); + $iterator = new SetKey($client, 'key:set', 'member:*', 2); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -395,7 +395,7 @@ class SetIteratorTest extends StandardTestCase ->with('key:set', 1, array('MATCH' => 'member:*', 'COUNT' => 1)) ->will($this->returnValue(array(0, array('member:2nd')))); - $iterator = new SetIterator($client, 'key:set', 'member:*', 1); + $iterator = new SetKey($client, 'key:set', 'member:*', 1); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -426,7 +426,7 @@ class SetIteratorTest extends StandardTestCase ->with('key:set', 0, array()) ->will($this->returnValue(array(0, array('member:1st', 'member:2nd')))); - $iterator = new SetIterator($client, 'key:set'); + $iterator = new SetKey($client, 'key:set'); $iterator->rewind(); $this->assertTrue($iterator->valid()); diff --git a/tests/Predis/Collection/Iterator/SortedSetIteratorTest.php b/tests/Predis/Collection/Iterator/SortedSetKeyTest.php similarity index 94% rename from tests/Predis/Collection/Iterator/SortedSetIteratorTest.php rename to tests/Predis/Collection/Iterator/SortedSetKeyTest.php index 9bdfeff7..c4485052 100644 --- a/tests/Predis/Collection/Iterator/SortedSetIteratorTest.php +++ b/tests/Predis/Collection/Iterator/SortedSetKeyTest.php @@ -19,7 +19,7 @@ use Predis\Profile\ServerProfile; /** * @group realm-iterators */ -class SortedSetIteratorTest extends StandardTestCase +class SortedSetTest extends StandardTestCase { /** * @group disconnected @@ -34,7 +34,7 @@ class SortedSetIteratorTest extends StandardTestCase ->method('getProfile') ->will($this->returnValue(ServerProfile::get('2.0'))); - $iterator = new SortedSetIterator($client, 'key:zset'); + $iterator = new SortedSetKey($client, 'key:zset'); } /** @@ -52,7 +52,7 @@ class SortedSetIteratorTest extends StandardTestCase ->with('key:zset', 0, array()) ->will($this->returnValue(array(0, array()))); - $iterator = new SortedSetIterator($client, 'key:zset'); + $iterator = new SortedSetKey($client, 'key:zset'); $iterator->rewind(); $this->assertFalse($iterator->valid()); @@ -75,7 +75,7 @@ class SortedSetIteratorTest extends StandardTestCase array('member:1st', 1.0), array('member:2nd', 2.0), array('member:3rd', 3.0), )))); - $iterator = new SortedSetIterator($client, 'key:zset'); + $iterator = new SortedSetKey($client, 'key:zset'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -119,7 +119,7 @@ class SortedSetIteratorTest extends StandardTestCase array('member:3rd', 3.0), )))); - $iterator = new SortedSetIterator($client, 'key:zset'); + $iterator = new SortedSetKey($client, 'key:zset'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -161,7 +161,7 @@ class SortedSetIteratorTest extends StandardTestCase array('member:1st', 1.0), array('member:2nd', 2.0), )))); - $iterator = new SortedSetIterator($client, 'key:zset'); + $iterator = new SortedSetKey($client, 'key:zset'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -204,7 +204,7 @@ class SortedSetIteratorTest extends StandardTestCase array('member:3rd', 3.0) )))); - $iterator = new SortedSetIterator($client, 'key:zset'); + $iterator = new SortedSetKey($client, 'key:zset'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -242,7 +242,7 @@ class SortedSetIteratorTest extends StandardTestCase array('member:1st', 1.0), array('member:2nd', 2.0), )))); - $iterator = new SortedSetIterator($client, 'key:zset', 'member:*'); + $iterator = new SortedSetKey($client, 'key:zset', 'member:*'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -281,7 +281,7 @@ class SortedSetIteratorTest extends StandardTestCase array('member:2nd', 2.0), )))); - $iterator = new SortedSetIterator($client, 'key:zset', 'member:*'); + $iterator = new SortedSetKey($client, 'key:zset', 'member:*'); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -314,7 +314,7 @@ class SortedSetIteratorTest extends StandardTestCase array('member:1st', 1.0), array('member:2nd', 2.0), )))); - $iterator = new SortedSetIterator($client, 'key:zset', null, 2); + $iterator = new SortedSetKey($client, 'key:zset', null, 2); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -353,7 +353,7 @@ class SortedSetIteratorTest extends StandardTestCase array('member:2nd', 2.0), )))); - $iterator = new SortedSetIterator($client, 'key:zset', null, 1); + $iterator = new SortedSetKey($client, 'key:zset', null, 1); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -386,7 +386,7 @@ class SortedSetIteratorTest extends StandardTestCase array('member:1st', 1.0), array('member:2nd', 2.0), )))); - $iterator = new SortedSetIterator($client, 'key:zset', 'member:*', 2); + $iterator = new SortedSetKey($client, 'key:zset', 'member:*', 2); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -425,7 +425,7 @@ class SortedSetIteratorTest extends StandardTestCase array('member:2nd', 2.0), )))); - $iterator = new SortedSetIterator($client, 'key:zset', 'member:*', 1); + $iterator = new SortedSetKey($client, 'key:zset', 'member:*', 1); $iterator->rewind(); $this->assertTrue($iterator->valid()); @@ -458,7 +458,7 @@ class SortedSetIteratorTest extends StandardTestCase array('member:1st', 1.0), array('member:2nd', 2.0), )))); - $iterator = new SortedSetIterator($client, 'key:zset'); + $iterator = new SortedSetKey($client, 'key:zset'); $iterator->rewind(); $this->assertTrue($iterator->valid());