From 08adcb478d94c04685cd2f6f3a3f30adff981f2f Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Sat, 24 Apr 2010 13:16:34 +0200 Subject: [PATCH] Test suite: added HLEN. --- test/RedisCommandsTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/RedisCommandsTest.php b/test/RedisCommandsTest.php index e4b63048..64c06bdf 100644 --- a/test/RedisCommandsTest.php +++ b/test/RedisCommandsTest.php @@ -1494,6 +1494,21 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase { }); } + function testHashLength() { + $this->assertTrue($this->redis->hset('metavars', 'foo', 'bar')); + $this->assertTrue($this->redis->hset('metavars', 'hoge', 'piyo')); + $this->assertTrue($this->redis->hset('metavars', 'foofoo', 'barbar')); + $this->assertTrue($this->redis->hset('metavars', 'hogehoge', 'piyopiyo')); + + $this->assertEquals(4, $this->redis->hlen('metavars')); + $this->assertEquals(0, $this->redis->hlen('hashDoesNotExist')); + + RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) { + $test->redis->set('foo', 'bar'); + $test->redis->hlen('foo'); + }); + } + function testHashSetPreserve() { $this->assertTrue($this->redis->hsetnx('metavars', 'foo', 'bar')); $this->assertFalse($this->redis->hsetnx('metavars', 'foo', 'barbar'));