Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 68cf720

Browse files
Skip GEO* tests if version < 3.2.0
1 parent 30a1c36 commit 68cf720

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

tests/RedisTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ public function setUp() {
2727
$this->version = (isset($info['redis_version'])?$info['redis_version']:'0.0.0');
2828
}
2929

30+
protected function minVersionCheck($version) {
31+
return version_compare($this->version, $version, "ge");
32+
}
33+
3034
protected function newInstance() {
3135
$r = new Redis();
3236

@@ -4782,6 +4786,10 @@ protected function addCities($key) {
47824786

47834787
/* GEOADD */
47844788
public function testGeoAdd() {
4789+
if (!$this->minVersionCheck("3.2")) {
4790+
return $this->markTestSkipped();
4791+
}
4792+
47854793
$this->redis->del('geokey');
47864794

47874795
/* Add them one at a time */
@@ -4801,6 +4809,10 @@ public function testGeoAdd() {
48014809

48024810
/* GEORADIUS */
48034811
public function genericGeoRadiusTest($cmd) {
4812+
if (!$this->minVersionCheck("3.2.0")) {
4813+
return $this->markTestSkipped();
4814+
}
4815+
48044816
/* Chico */
48054817
$city = 'Chico';
48064818
$lng = -121.837478;
@@ -4868,26 +4880,46 @@ public function genericGeoRadiusTest($cmd) {
48684880
}
48694881

48704882
public function testGeoRadius() {
4883+
if (!$this->minVersionCheck("3.2.0")) {
4884+
return $this->markTestSkipped();
4885+
}
4886+
48714887
$this->genericGeoRadiusTest('georadius');
48724888
}
48734889

48744890
public function testGeoRadiusByMember() {
4891+
if (!$this->minVersionCheck("3.2.0")) {
4892+
return $this->markTestSkipped();
4893+
}
4894+
48754895
$this->genericGeoRadiusTest('georadiusbymember');
48764896
}
48774897

48784898
public function testGeoPos() {
4899+
if (!$this->minVersionCheck("3.2.0")) {
4900+
return $this->markTestSkipped();
4901+
}
4902+
48794903
$this->addCities('gk');
48804904
$this->assertEquals($this->redis->geopos('gk', 'Chico', 'Sacramento'), $this->rawCommandArray('gk', Array('geopos', 'gk', 'Chico', 'Sacramento')));
48814905
$this->assertEquals($this->redis->geopos('gk', 'Cupertino'), $this->rawCommandArray('gk', Array('geopos', 'gk', 'Cupertino')));
48824906
}
48834907

48844908
public function testGeoHash() {
4909+
if (!$this->minVersionCheck("3.2.0")) {
4910+
return $this->markTestSkipped();
4911+
}
4912+
48854913
$this->addCities('gk');
48864914
$this->assertEquals($this->redis->geohash('gk', 'Chico', 'Sacramento'), $this->rawCommandArray('gk', Array('geohash', 'gk', 'Chico', 'Sacramento')));
48874915
$this->assertEquals($this->redis->geohash('gk', 'Chico'), $this->rawCommandArray('gk', Array('geohash', 'gk', 'Chico')));
48884916
}
48894917

48904918
public function testGeoDist() {
4919+
if (!$this->minVersionCheck("3.2.0")) {
4920+
return $this->markTestSkipped();
4921+
}
4922+
48914923
$this->addCities('gk');
48924924

48934925
$r1 = $this->redis->geodist('gk', 'Chico', 'Cupertino');

tests/TestRedis.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
require_once(dirname($_SERVER['PHP_SELF'])."/RedisClusterTest.php");
77

88
/* Make sure errors go to stdout and are shown */
9-
error_reporting(E_ALL);
9+
error_reporting(E_ALL);
1010
ini_set( 'display_errors','1');
1111

1212
/* Grab options */

0 commit comments

Comments
 (0)