Skip to content

Commit 2516eb2

Browse files
committed
proposal for multi-version test suite ("All tests passed." with 2.6.0RC6)
1 parent ac09cec commit 2516eb2

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

tests/TestRedis.php

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class Redis_Test extends TestSuite
1818
public function setUp()
1919
{
2020
$this->redis = $this->newInstance();
21+
$info = $this->redis->info();
22+
$this->version = (isset($info['redis_version'])?$info['redis_version']:'0.0.0');
2123
}
2224

2325
private function newInstance() {
@@ -44,6 +46,12 @@ public function reset()
4446
$this->tearDown();
4547
}
4648

49+
public function testMinimumVersion()
50+
{
51+
// Minimum server version required for tests
52+
$this->assertTrue(version_compare($this->version, "2.4.0", "ge"));
53+
}
54+
4755
public function testPing()
4856
{
4957

@@ -848,8 +856,14 @@ public function testSortAsc() {
848856
}
849857

850858
// SORT list → [ghi, def, abc]
851-
$this->assertEquals(array_reverse($list), $this->redis->sortAsc('list'));
852-
$this->assertEquals(array_reverse($list), $this->redis->sort('list', array('sort' => 'asc')));
859+
if (version_compare($this->version, "2.5.0", "lt")) {
860+
$this->assertEquals(array_reverse($list), $this->redis->sortAsc('list'));
861+
$this->assertEquals(array_reverse($list), $this->redis->sort('list', array('sort' => 'asc')));
862+
} else {
863+
// TODO rewrite, from 2.6.0 release notes:
864+
// SORT now will refuse to sort in numerical mode elements that can't be parsed
865+
// as numbers
866+
}
853867

854868
// SORT list ALPHA → [abc, def, ghi]
855869
$this->assertEquals($list, $this->redis->sortAscAlpha('list'));
@@ -883,7 +897,13 @@ public function testSortDesc() {
883897
}
884898

885899
// SORT list → [ghi, abc, def]
886-
$this->assertEquals(array_reverse($list), $this->redis->sortDesc('list'));
900+
if (version_compare($this->version, "2.5.0", "lt")) {
901+
$this->assertEquals(array_reverse($list), $this->redis->sortDesc('list'));
902+
} else {
903+
// TODO rewrite, from 2.6.0 release notes:
904+
// SORT now will refuse to sort in numerical mode elements that can't be parsed
905+
// as numbers
906+
}
887907

888908
// SORT list ALPHA → [abc, def, ghi]
889909
$this->assertEquals(array('ghi', 'def', 'abc'), $this->redis->sortDescAlpha('list'));
@@ -1580,13 +1600,22 @@ public function testinfo() {
15801600
"connected_clients",
15811601
"connected_slaves",
15821602
"used_memory",
1583-
"changes_since_last_save",
1584-
"bgsave_in_progress",
1585-
"last_save_time",
15861603
"total_connections_received",
15871604
"total_commands_processed",
15881605
"role");
1589-
1606+
if (version_compare($this->version, "2.5.0", "lt")) {
1607+
array_push($keys,
1608+
"changes_since_last_save",
1609+
"bgsave_in_progress",
1610+
"last_save_time"
1611+
);
1612+
} else {
1613+
array_push($keys,
1614+
"rdb_changes_since_last_save",
1615+
"rdb_bgsave_in_progress",
1616+
"rdb_last_save_time"
1617+
);
1618+
}
15901619

15911620
foreach($keys as $k) {
15921621
$this->assertTrue(in_array($k, array_keys($info)));

0 commit comments

Comments
 (0)