mirror of
https://github.com/predis/predis.git
synced 2026-08-30 04:02:22 +00:00
Test suite: added SETEX.
This commit is contained in:
@@ -321,6 +321,26 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
|
||||
$this->assertEquals(-1, $this->redis->ttl('foo'));
|
||||
}
|
||||
|
||||
function testSetExpire() {
|
||||
$this->assertTrue($this->redis->setex('foo', 10, 'bar'));
|
||||
$this->assertTrue($this->redis->exists('foo'));
|
||||
$this->assertEquals(10, $this->redis->ttl('foo'));
|
||||
|
||||
$this->assertTrue($this->redis->setex('hoge', 1, 'piyo'));
|
||||
sleep(2);
|
||||
$this->assertFalse($this->redis->exists('hoge'));
|
||||
|
||||
RC::testForServerException($this, RC::EXCEPTION_VALUE_NOT_INT, function($test) {
|
||||
$test->redis->setex('hoge', 2.5, 'piyo');
|
||||
});
|
||||
RC::testForServerException($this, RC::EXCEPTION_SETEX_TTL, function($test) {
|
||||
$test->redis->setex('hoge', 0, 'piyo');
|
||||
});
|
||||
RC::testForServerException($this, RC::EXCEPTION_SETEX_TTL, function($test) {
|
||||
$test->redis->setex('hoge', -10, 'piyo');
|
||||
});
|
||||
}
|
||||
|
||||
function testDatabaseSize() {
|
||||
// TODO: is this really OK?
|
||||
$this->assertEquals(0, $this->redis->dbsize());
|
||||
|
||||
Reference in New Issue
Block a user