Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpredis/phpredis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormichael-grunder <michael.grunder@gmail.com>2019-04-16 17:57:40 +0300
committerMichael Grunder <michael.grunder@gmail.com>2019-04-16 18:16:12 +0300
commitd7450b2f59700e4662624317438c456a0dd36165 (patch)
tree01114daffdc930b85039356e75138d5b7b6afa05 /tests
parent5bf0c84c8fc7411e3d1dbee821c96b5a73561849 (diff)
Add support for STREAM to the type command
Diffstat (limited to 'tests')
-rw-r--r--tests/RedisTest.php94
1 files changed, 52 insertions, 42 deletions
diff --git a/tests/RedisTest.php b/tests/RedisTest.php
index a865ffd7..9f92c780 100644
--- a/tests/RedisTest.php
+++ b/tests/RedisTest.php
@@ -696,47 +696,57 @@ class Redis_Test extends TestSuite
public function testType()
{
- // 0 => none, (key didn't exist)
- // 1=> string,
- // 2 => set,
- // 3 => list,
- // 4 => zset,
- // 5 => hash
-
- // string
- $this->redis->set('key', 'val');
- $this->assertEquals(Redis::REDIS_STRING, $this->redis->type('key'));
-
- // list
- $this->redis->lPush('keyList', 'val0');
- $this->redis->lPush('keyList', 'val1');
- $this->assertEquals(Redis::REDIS_LIST, $this->redis->type('keyList'));
-
- // set
- $this->redis->del('keySet');
- $this->redis->sAdd('keySet', 'val0');
- $this->redis->sAdd('keySet', 'val1');
- $this->assertEquals(Redis::REDIS_SET, $this->redis->type('keySet'));
-
- // sadd with numeric key
- $this->redis->del(123);
- $this->assertTrue(1 === $this->redis->sAdd(123, 'val0'));
- $this->assertTrue(['val0'] === $this->redis->sMembers(123));
-
- // zset
- $this->redis->del('keyZSet');
- $this->redis->zAdd('keyZSet', 0, 'val0');
- $this->redis->zAdd('keyZSet', 1, 'val1');
- $this->assertEquals(Redis::REDIS_ZSET, $this->redis->type('keyZSet'));
-
- // hash
- $this->redis->del('keyHash');
- $this->redis->hSet('keyHash', 'key0', 'val0');
- $this->redis->hSet('keyHash', 'key1', 'val1');
- $this->assertEquals(Redis::REDIS_HASH, $this->redis->type('keyHash'));
-
- //None
- $this->assertEquals(Redis::REDIS_NOT_FOUND, $this->redis->type('keyNotExists'));
+ // 0 => none, (key didn't exist)
+ // 1=> string,
+ // 2 => set,
+ // 3 => list,
+ // 4 => zset,
+ // 5 => hash
+ // 6 => stream
+
+ // string
+ $this->redis->set('key', 'val');
+ $this->assertEquals(Redis::REDIS_STRING, $this->redis->type('key'));
+
+ // list
+ $this->redis->lPush('keyList', 'val0');
+ $this->redis->lPush('keyList', 'val1');
+ $this->assertEquals(Redis::REDIS_LIST, $this->redis->type('keyList'));
+
+ // set
+ $this->redis->del('keySet');
+ $this->redis->sAdd('keySet', 'val0');
+ $this->redis->sAdd('keySet', 'val1');
+ $this->assertEquals(Redis::REDIS_SET, $this->redis->type('keySet'));
+
+ // sadd with numeric key
+ $this->redis->del(123);
+ $this->assertTrue(1 === $this->redis->sAdd(123, 'val0'));
+ $this->assertTrue(['val0'] === $this->redis->sMembers(123));
+
+ // zset
+ $this->redis->del('keyZSet');
+ $this->redis->zAdd('keyZSet', 0, 'val0');
+ $this->redis->zAdd('keyZSet', 1, 'val1');
+ $this->assertEquals(Redis::REDIS_ZSET, $this->redis->type('keyZSet'));
+
+ // hash
+ $this->redis->del('keyHash');
+ $this->redis->hSet('keyHash', 'key0', 'val0');
+ $this->redis->hSet('keyHash', 'key1', 'val1');
+ $this->assertEquals(Redis::REDIS_HASH, $this->redis->type('keyHash'));
+
+ // stream
+ if ($this->minVersionCheck("5.0")) {
+ $this->redis->del('stream');
+ $this->redis->xAdd('stream', '*', ['foo' => 'bar']);
+ $this->assertEquals(Redis::REDIS_STREAM, $this->redis->type('stream'));
+ }
+
+ // None
+ $this->redis->del('keyNotExists');
+ $this->assertEquals(Redis::REDIS_NOT_FOUND, $this->redis->type('keyNotExists'));
+
}
public function testStr() {
@@ -2447,7 +2457,7 @@ class Redis_Test extends TestSuite
$this->redis->del('key');
$this->redis->zAdd('key', 0, 'a', 1, 'b', 2, 'c', 3, 'd', 4, 'e');
$this->assertTrue(array('e' => 4.0, 'd' => 3.0, 'c' => 2.0) === $this->redis->zPopMax('key', 3));
-
+
// zPopMin with a COUNT argument
$this->redis->del('key');
$this->redis->zAdd('key', 0, 'a', 1, 'b', 2, 'c', 3, 'd', 4, 'e');