Browse Source

Test suite: added HKEYS, HVALS, HGETALL.

Daniele Alessandri 15 years ago
parent
commit
0d4426c052
1 changed files with 39 additions and 0 deletions
  1. 39 0
      test/RedisCommandsTest.php

+ 39 - 0
test/RedisCommandsTest.php

@@ -1549,6 +1549,45 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
         });
     }
 
+    function testHashKeys() {
+        $hashKVs = array('foo' => 'bar', 'hoge' => 'piyo');
+        $this->assertTrue($this->redis->hmset('metavars', $hashKVs));
+
+        $this->assertEquals(array_keys($hashKVs), $this->redis->hkeys('metavars'));
+        $this->assertEquals(array(), $this->redis->hkeys('hashDoesNotExist'));
+
+        RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) {
+            $test->redis->set('foo', 'bar');
+            $test->redis->hkeys('foo');
+        });
+    }
+
+    function testHashValues() {
+        $hashKVs = array('foo' => 'bar', 'hoge' => 'piyo');
+        $this->assertTrue($this->redis->hmset('metavars', $hashKVs));
+
+        $this->assertEquals(array_values($hashKVs), $this->redis->hvals('metavars'));
+        $this->assertEquals(array(), $this->redis->hvals('hashDoesNotExist'));
+
+        RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) {
+            $test->redis->set('foo', 'bar');
+            $test->redis->hvals('foo');
+        });
+    }
+
+    function testHashGetAll() {
+        $hashKVs = array('foo' => 'bar', 'hoge' => 'piyo');
+        $this->assertTrue($this->redis->hmset('metavars', $hashKVs));
+
+        $this->assertEquals($hashKVs, $this->redis->hgetall('metavars'));
+        $this->assertEquals(array(), $this->redis->hgetall('hashDoesNotExist'));
+
+        RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) {
+            $test->redis->set('foo', 'bar');
+            $test->redis->hgetall('foo');
+        });
+    }
+
     /* multiple databases handling commands */
 
     function testSelectDatabase() {