From 418197af75c7a16b31b4e011c7a1643b6dbda1f2 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Wed, 7 Jul 2010 19:34:25 +0200 Subject: [PATCH] Add tests for the new options handling for the ZRANGE commands family. --- test/RedisCommandsTest.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/RedisCommandsTest.php b/test/RedisCommandsTest.php index 08e85a7c..0920ea9b 100644 --- a/test/RedisCommandsTest.php +++ b/test/RedisCommandsTest.php @@ -1095,6 +1095,11 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase { $this->redis->zrange('zset', 0, 2, 'withscores') ); + $this->assertEquals( + array(array('a', -10), array('b', 0), array('c', 10)), + $this->redis->zrange('zset', 0, 2, array('withscores' => true)) + ); + RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) { $test->redis->set('foo', 'bar'); $test->redis->zrange('foo', 0, -1); @@ -1149,6 +1154,11 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase { $this->redis->zrevrange('zset', 0, 2, 'withscores') ); + $this->assertEquals( + array(array('f', 30), array('e', 20), array('d', 20)), + $this->redis->zrevrange('zset', 0, 2, array('withscores' => true)) + ); + RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) { $test->redis->set('foo', 'bar'); $test->redis->zrevrange('foo', 0, -1); @@ -1183,6 +1193,24 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase { $this->redis->zrangebyscore('zset', 10, 20, 'withscores') ); + $this->assertEquals( + array(array('c', 10), array('d', 20), array('e', 20)), + $this->redis->zrangebyscore('zset', 10, 20, array('withscores' => true)) + ); + + $this->assertEquals( + array('d', 'e'), + $this->redis->zrangebyscore('zset', 10, 20, array('limit' => array(1, 2))) + ); + + $this->assertEquals( + array(array('d', 20), array('e', 20)), + $this->redis->zrangebyscore('zset', 10, 20, array( + 'limit' => array(1, 2), + 'withscores' => true, + )) + ); + RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) { $test->redis->set('foo', 'bar'); $test->redis->zrangebyscore('foo', 0, 0);