From 81484b3351218ea96bede60692b5e16edda806b9 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Sat, 19 Dec 2009 10:46:09 +0100 Subject: [PATCH] Added tests for Predis\Commands\ZSetIncrementBy (ZINCRBY). --- test/RedisCommandsTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/RedisCommandsTest.php b/test/RedisCommandsTest.php index 1bddb2a4..4dce3f99 100644 --- a/test/RedisCommandsTest.php +++ b/test/RedisCommandsTest.php @@ -866,6 +866,26 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase { }); } + function testZsetIncrementBy() { + $this->assertEquals(1, $this->redis->zsetIncrementBy('zsetDoesNotExist', 1, 'foo')); + $this->assertEquals('zset', $this->redis->type('zsetDoesNotExist')); + + RC::zsetAddAndReturn($this->redis, 'zset', RC::getZSetArray()); + $this->assertEquals(-5, $this->redis->zsetIncrementBy('zset', 5, 'a')); + $this->assertEquals(1, $this->redis->zsetIncrementBy('zset', 1, 'b')); + $this->assertEquals(10, $this->redis->zsetIncrementBy('zset', 0, 'c')); + $this->assertEquals(0, $this->redis->zsetIncrementBy('zset', -20, 'd')); + $this->assertEquals(2, $this->redis->zsetIncrementBy('zset', 2, 'd')); + $this->assertEquals(-10, $this->redis->zsetIncrementBy('zset', -30, 'e')); + $this->assertEquals(1, $this->redis->zsetIncrementBy('zset', 1, 'x')); + + // wrong type + $this->redis->set('foo', 'bar'); + RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) { + $test->redis->zsetIncrementBy('foo', 1, 'a'); + }); + } + function testZsetRemove() { RC::zsetAddAndReturn($this->redis, 'zset', RC::getZSetArray());