فهرست منبع

Test suite: added HLEN.

Daniele Alessandri 15 سال پیش
والد
کامیت
08adcb478d
1فایلهای تغییر یافته به همراه15 افزوده شده و 0 حذف شده
  1. 15 0
      test/RedisCommandsTest.php

+ 15 - 0
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'));