Skip to content

Commit 5df5153

Browse files
committed
Merge pull request phpredis#242 from remicollet/master
Skip test according to server version * INCRBYFLOAT new in 2.6.0 * INFO COMMANDSTATS is new in 2.6.0 * INFO COMMANDSTATS is new in 2.6.0 * SCRIPT / EVAL / TIME are new in 2.6.0
2 parents 5ff5b24 + a968d9e commit 5df5153

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

tests/TestRedis.php

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,14 @@ public function testIncr()
383383

384384
$this->redis->incr('key');
385385
$this->assertTrue("abc" === $this->redis->get('key'));
386+
}
386387

387-
// incrbyfloat
388+
public function testIncrByFloat()
389+
{
390+
// incrbyfloat is new in 2.6.0
391+
if (version_compare($this->version, "2.5.0", "lt")) {
392+
return;
393+
}
388394

389395
$this->redis->delete('key');
390396

@@ -1620,8 +1626,15 @@ public function testinfo() {
16201626
foreach($keys as $k) {
16211627
$this->assertTrue(in_array($k, array_keys($info)));
16221628
}
1629+
}
1630+
1631+
public function testInfoCommandStats() {
1632+
1633+
// INFO COMMANDSTATS is new in 2.6.0
1634+
if (version_compare($this->version, "2.5.0", "lt")) {
1635+
return;
1636+
}
16231637

1624-
// INFO COMMANDSTATS
16251638
$info = $this->redis->info("COMMANDSTATS");
16261639

16271640
$this->assertTrue(is_array($info));
@@ -2024,6 +2037,7 @@ public function testHashes() {
20242037
$this->redis->hSet('h', 'y', 'not-a-number');
20252038
$this->assertTrue(FALSE === $this->redis->hIncrBy('h', 'y', 1));
20262039

2040+
if (version_compare($this->version, "2.5.0", "ge")) {
20272041
// hIncrByFloat
20282042
$this->redis->delete('h');
20292043
$this->assertTrue(1.5 === $this->redis->hIncrByFloat('h','x', 1.5));
@@ -2032,6 +2046,7 @@ public function testHashes() {
20322046

20332047
$this->redis->hset('h','y','not-a-number');
20342048
$this->assertTrue(FALSE === $this->redis->hIncrByFloat('h', 'y', 1.5));
2049+
}
20352050

20362051
// hmset
20372052
$this->redis->delete('h');
@@ -2971,6 +2986,11 @@ private function checkSerializer($mode) {
29712986
}
29722987

29732988
public function testDumpRestore() {
2989+
2990+
if (version_compare($this->version, "2.5.0", "lt")) {
2991+
return;
2992+
}
2993+
29742994
$this->redis->del('foo');
29752995
$this->redis->del('bar');
29762996

@@ -3031,6 +3051,11 @@ private function array_diff_recursive($aArray1, $aArray2) {
30313051
}
30323052

30333053
public function testScript() {
3054+
3055+
if (version_compare($this->version, "2.5.0", "lt")) {
3056+
return;
3057+
}
3058+
30343059
// Flush any scripts we have
30353060
$this->assertTrue($this->redis->script('flush'));
30363061

@@ -3058,6 +3083,11 @@ public function testScript() {
30583083
}
30593084

30603085
public function testEval() {
3086+
3087+
if (version_compare($this->version, "2.5.0", "lt")) {
3088+
return;
3089+
}
3090+
30613091
// Basic single line response tests
30623092
$this->assertTrue(1 == $this->redis->eval('return 1'));
30633093
$this->assertTrue(1.55 == $this->redis->eval("return '1.55'"));
@@ -3171,6 +3201,11 @@ public function testEval() {
31713201
}
31723202

31733203
public function testEvalSHA() {
3204+
3205+
if (version_compare($this->version, "2.5.0", "lt")) {
3206+
return;
3207+
}
3208+
31743209
// Flush any loaded scripts
31753210
$this->redis->script('flush');
31763211

@@ -3264,6 +3299,11 @@ public function testReconnectSelect() {
32643299
}
32653300

32663301
public function testTime() {
3302+
3303+
if (version_compare($this->version, "2.5.0", "lt")) {
3304+
return;
3305+
}
3306+
32673307
$time_arr = $this->redis->time();
32683308
$this->assertTrue(is_array($time_arr) && count($time_arr) == 2 &&
32693309
strval(intval($time_arr[0])) === strval($time_arr[0]) &&

0 commit comments

Comments
 (0)