Explorar el Código

[tests] Improve tests of TTL.

Daniele Alessandri hace 11 años
padre
commit
09b0750cb7
Se han modificado 1 ficheros con 6 adiciones y 4 borrados
  1. 6 4
      tests/Predis/Command/KeyTimeToLiveTest.php

+ 6 - 4
tests/Predis/Command/KeyTimeToLiveTest.php

@@ -85,13 +85,15 @@ class KeyTimeToLiveTest extends CommandTestCase
 
     /**
      * @group connected
-     * @todo TTL changed in Redis >= 2.8 to return -2 on non existing keys, we
-     *       should handle this case with a better solution than the current one.
      */
     public function testReturnsLessThanZeroOnNonExistingKeys()
     {
-        $redis = $this->getClient();
+        $this->executeOnRedisVersion('2.8.0', '<', function ($test) {
+            $test->assertSame(-1, $test->getClient()->ttl('foo'));
+        });
 
-        $this->assertLessThanOrEqual(-1, $redis->ttl('foo'));
+        $this->executeOnRedisVersion('2.8.0', '>=', function ($test) {
+            $test->assertSame(-2, $test->getClient()->ttl('foo'));
+        });
     }
 }