Browse Source

Add test guard for empty bulk replies.

Daniele Alessandri 14 years ago
parent
commit
65c530a13b
2 changed files with 12 additions and 1 deletions
  1. 8 0
      test/PredisClientFeatures.php
  2. 4 1
      test/RedisCommandsTest.php

+ 8 - 0
test/PredisClientFeatures.php

@@ -335,6 +335,14 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
         });
         });
     }
     }
 
 
+    function testResponseReader_EmptyBulkResponse() {
+        $client = new \Predis\Client();
+        $client->getConnection()->setProtocol(new \Predis\Protocols\ComposableTextProtocol());
+
+        $this->assertTrue($client->set('foo', ''));
+        $this->assertEquals('', $client->get('foo'));
+        $this->assertEquals('', $client->get('foo'));
+    }
 
 
     /* Client initialization */
     /* Client initialization */
 
 

+ 4 - 1
test/RedisCommandsTest.php

@@ -86,8 +86,11 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
 
 
     function testGet() {
     function testGet() {
         $this->redis->set('foo', 'bar');
         $this->redis->set('foo', 'bar');
-
         $this->assertEquals('bar', $this->redis->get('foo'));
         $this->assertEquals('bar', $this->redis->get('foo'));
+
+        $this->assertTrue($this->redis->set('foo', ''));
+        $this->assertEquals('', $this->redis->get('foo'));
+
         $this->assertNull($this->redis->get('fooDoesNotExist'));
         $this->assertNull($this->redis->get('fooDoesNotExist'));
 
 
         // should throw an exception when trying to do a GET on non-string types
         // should throw an exception when trying to do a GET on non-string types