Skip to content

Commit

Permalink
Skip GEO* tests if version < 3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-grunder committed Jun 10, 2016
1 parent 30a1c36 commit 68cf720
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions tests/RedisTest.php
Expand Up @@ -27,6 +27,10 @@ public function setUp() {
$this->version = (isset($info['redis_version'])?$info['redis_version']:'0.0.0');
}

protected function minVersionCheck($version) {
return version_compare($this->version, $version, "ge");
}

protected function newInstance() {
$r = new Redis();

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

/* GEOADD */
public function testGeoAdd() {
if (!$this->minVersionCheck("3.2")) {
return $this->markTestSkipped();
}

$this->redis->del('geokey');

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

/* GEORADIUS */
public function genericGeoRadiusTest($cmd) {
if (!$this->minVersionCheck("3.2.0")) {
return $this->markTestSkipped();
}

/* Chico */
$city = 'Chico';
$lng = -121.837478;
Expand Down Expand Up @@ -4868,26 +4880,46 @@ public function genericGeoRadiusTest($cmd) {
}

public function testGeoRadius() {
if (!$this->minVersionCheck("3.2.0")) {
return $this->markTestSkipped();
}

$this->genericGeoRadiusTest('georadius');
}

public function testGeoRadiusByMember() {
if (!$this->minVersionCheck("3.2.0")) {
return $this->markTestSkipped();
}

$this->genericGeoRadiusTest('georadiusbymember');
}

public function testGeoPos() {
if (!$this->minVersionCheck("3.2.0")) {
return $this->markTestSkipped();
}

$this->addCities('gk');
$this->assertEquals($this->redis->geopos('gk', 'Chico', 'Sacramento'), $this->rawCommandArray('gk', Array('geopos', 'gk', 'Chico', 'Sacramento')));
$this->assertEquals($this->redis->geopos('gk', 'Cupertino'), $this->rawCommandArray('gk', Array('geopos', 'gk', 'Cupertino')));
}

public function testGeoHash() {
if (!$this->minVersionCheck("3.2.0")) {
return $this->markTestSkipped();
}

$this->addCities('gk');
$this->assertEquals($this->redis->geohash('gk', 'Chico', 'Sacramento'), $this->rawCommandArray('gk', Array('geohash', 'gk', 'Chico', 'Sacramento')));
$this->assertEquals($this->redis->geohash('gk', 'Chico'), $this->rawCommandArray('gk', Array('geohash', 'gk', 'Chico')));
}

public function testGeoDist() {
if (!$this->minVersionCheck("3.2.0")) {
return $this->markTestSkipped();
}

$this->addCities('gk');

$r1 = $this->redis->geodist('gk', 'Chico', 'Cupertino');
Expand Down
2 changes: 1 addition & 1 deletion tests/TestRedis.php
Expand Up @@ -6,7 +6,7 @@
require_once(dirname($_SERVER['PHP_SELF'])."/RedisClusterTest.php");

/* Make sure errors go to stdout and are shown */
error_reporting(E_ALL);
error_reporting(E_ALL);
ini_set( 'display_errors','1');

/* Grab options */
Expand Down

0 comments on commit 68cf720

Please sign in to comment.