Added tests for MULTI / EXEC.

This commit is contained in:
Daniele Alessandri
2009-12-31 13:00:27 +01:00
parent e637881c2d
commit db6e40df98
2 changed files with 20 additions and 0 deletions
+1
View File
@@ -21,6 +21,7 @@ class RC {
const EXCEPTION_NO_SUCH_KEY = 'no such key';
const EXCEPTION_OUT_OF_RANGE = 'index out of range';
const EXCEPTION_INVALID_DB_IDX = 'invalid DB index';
const EXCEPTION_EXEC_NO_MULTI = 'EXEC without MULTI';
private static $_connection;
+19
View File
@@ -45,6 +45,25 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$this->assertFalse($this->redis->isConnected());
}
function testMultiExec() {
// NOTE: due to a limitation in the current implementation of Predis\Client,
// the replies returned by Predis\Command\Exec are not parsed by their
// respective Predis\Command::parseResponse methods. If you need that
// kind of behaviour, you should use an instance of Predis\MultiExecBlock.
$this->assertTrue($this->redis->multi());
$this->assertType('Predis\ResponseQueued', $this->redis->ping());
$this->assertType('Predis\ResponseQueued', $this->redis->echo('hello'));
$this->assertType('Predis\ResponseQueued', $this->redis->echo('redis'));
$this->assertEquals(array('PONG', 'hello', 'redis'), $this->redis->exec());
$this->assertTrue($this->redis->multi());
$this->assertEquals(array(), $this->redis->exec());
// should throw an exception when trying to EXEC without having previously issued MULTI
RC::testForServerException($this, RC::EXCEPTION_EXEC_NO_MULTI, function($test) {
$test->redis->exec();
});
}
/* commands operating on string values */