From 65c530a13baedec0ef15fa000509e64d7c6f6ea5 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Sat, 12 Feb 2011 21:14:54 +0100 Subject: [PATCH] Add test guard for empty bulk replies. --- test/PredisClientFeatures.php | 8 ++++++++ test/RedisCommandsTest.php | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/test/PredisClientFeatures.php b/test/PredisClientFeatures.php index 14cc81d0..aa876a94 100644 --- a/test/PredisClientFeatures.php +++ b/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 */ diff --git a/test/RedisCommandsTest.php b/test/RedisCommandsTest.php index f0efbbbc..296343f6 100644 --- a/test/RedisCommandsTest.php +++ b/test/RedisCommandsTest.php @@ -86,8 +86,11 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase { function testGet() { $this->redis->set('foo', 'bar'); - $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')); // should throw an exception when trying to do a GET on non-string types