@@ -18,6 +18,8 @@ class Redis_Test extends TestSuite
18
18
public function setUp ()
19
19
{
20
20
$ this ->redis = $ this ->newInstance ();
21
+ $ info = $ this ->redis ->info ();
22
+ $ this ->version = (isset ($ info ['redis_version ' ])?$ info ['redis_version ' ]:'0.0.0 ' );
21
23
}
22
24
23
25
private function newInstance () {
@@ -44,6 +46,12 @@ public function reset()
44
46
$ this ->tearDown ();
45
47
}
46
48
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
+
47
55
public function testPing ()
48
56
{
49
57
@@ -848,8 +856,14 @@ public function testSortAsc() {
848
856
}
849
857
850
858
// 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
+ }
853
867
854
868
// SORT list ALPHA → [abc, def, ghi]
855
869
$ this ->assertEquals ($ list , $ this ->redis ->sortAscAlpha ('list ' ));
@@ -883,7 +897,13 @@ public function testSortDesc() {
883
897
}
884
898
885
899
// 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
+ }
887
907
888
908
// SORT list ALPHA → [abc, def, ghi]
889
909
$ this ->assertEquals (array ('ghi ' , 'def ' , 'abc ' ), $ this ->redis ->sortDescAlpha ('list ' ));
@@ -1580,13 +1600,22 @@ public function testinfo() {
1580
1600
"connected_clients " ,
1581
1601
"connected_slaves " ,
1582
1602
"used_memory " ,
1583
- "changes_since_last_save " ,
1584
- "bgsave_in_progress " ,
1585
- "last_save_time " ,
1586
1603
"total_connections_received " ,
1587
1604
"total_commands_processed " ,
1588
1605
"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
+ }
1590
1619
1591
1620
foreach ($ keys as $ k ) {
1592
1621
$ this ->assertTrue (in_array ($ k , array_keys ($ info )));
0 commit comments