|
10 | 10 | */ |
11 | 11 | namespace Test\Integration\Version4x0; |
12 | 12 |
|
| 13 | +use RedisClient\Exception\ErrorResponseException; |
| 14 | + |
13 | 15 | include_once(__DIR__ . '/../Version3x2/GeoCommandsTest.php'); |
14 | 16 |
|
15 | 17 | class GeoCommandsTest extends \Test\Integration\Version3x2\GeoCommandsTest { |
16 | 18 |
|
| 19 | + /** |
| 20 | + * @see \RedisClient\Command\Traits\Version3x2\GeoCommandsTrait::geohash |
| 21 | + */ |
| 22 | + public function test_geohash() { |
| 23 | + $Redis = static::$Redis; |
| 24 | + |
| 25 | + $this->assertSame(2, $Redis->geoadd('Sicily', [ |
| 26 | + 'Palermo' => ['13.361389', '38.115556'], |
| 27 | + 'Catania' => ['15.087269', '37.502669'] |
| 28 | + ])); |
| 29 | + |
| 30 | + $this->assertSame(['sqc8b49rny0'], $Redis->geohash('Sicily', ['Palermo'])); |
| 31 | + $this->assertSame(['sqc8b49rny0', 'sqdtr74hyu0'], $Redis->geohash('Sicily', ['Palermo', 'Catania'])); |
| 32 | + $this->assertSame(['sqdtr74hyu0'], $Redis->geohash('Sicily', ['Catania'])); |
| 33 | + $this->assertSame([null], $Redis->geohash('Sicily', ['foo'])); |
| 34 | + $this->assertSame([null, 'sqc8b49rny0'], $Redis->geohash('Sicily', ['foo', 'Palermo'])); |
| 35 | + $this->assertSame([null, 'sqc8b49rny0', null], $Redis->geohash('Sicily', ['foo', 'Palermo', 'bar'])); |
| 36 | + $this->assertSame(['sqc8b49rny0', 'sqc8b49rny0'], $Redis->geohash('Sicily', ['Palermo', 'Palermo'])); |
| 37 | + |
| 38 | + $this->assertSame([null], $Redis->geohash('foo', ['a'])); |
| 39 | + $this->assertSame([null, null, null], $Redis->geohash('foo', ['a', 'b', 'c'])); |
| 40 | + |
| 41 | + $this->assertSame(null, $Redis->geodist('Sicily', 'Catania', 'foo', 'ft')); |
| 42 | + $this->assertSame(null, $Redis->geodist('Sicily', 'bar', 'foo')); |
| 43 | + |
| 44 | + $Redis->set('foo', 'bar'); |
| 45 | + $this->setExpectedException(ErrorResponseException::class); |
| 46 | + $Redis->geodist('foo', 'bar', 'foo'); |
| 47 | + } |
| 48 | + |
17 | 49 | } |
0 commit comments