Browse Source

Added tests for SUBSTR.

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

+ 13 - 0
test/RedisCommandsTest.php

@@ -205,6 +205,19 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
         });
     }
 
+    function testSubstr() {
+        $this->redis->set('var', 'foobar');
+        $this->assertEquals('foo', $this->redis->substr('var', 0, 2));
+        $this->assertEquals('bar', $this->redis->substr('var', 3, 5));
+        $this->assertEquals('bar', $this->redis->substr('var', -3, -1));
+        $this->assertNull($this->redis->substr('var', 5, 0));
+
+        RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) {
+            $test->redis->pushTail('metavars', 'foo');
+            $test->redis->substr('metavars', 0, 3);
+        });
+    }
+
     /* commands operating on the key space */
 
     function testKeys() {