瀏覽代碼

Test suite: added HGET.

Daniele Alessandri 15 年之前
父節點
當前提交
69bce63453
共有 1 個文件被更改,包括 14 次插入0 次删除
  1. 14 0
      test/RedisCommandsTest.php

+ 14 - 0
test/RedisCommandsTest.php

@@ -1458,6 +1458,20 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
         });
     }
 
+    function testHashGet() {
+        $this->assertTrue($this->redis->hset('metavars', 'foo', 'bar'));
+        $this->assertEquals('bar', $this->redis->hget('metavars', 'foo'));
+
+        $this->assertEquals('bar', $this->redis->hget('metavars', 'foo'));
+        $this->assertNull($this->redis->hget('metavars', 'hoge'));
+        $this->assertNull($this->redis->hget('hashDoesNotExist', 'field'));
+
+        RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) {
+            $test->redis->rpush('metavars', 'foo');
+            $test->redis->hget('metavars', 'foo');
+        });
+   }
+
     /* multiple databases handling commands */
 
     function testSelectDatabase() {