Преглед на файлове

[tests] TTL and PTTL return -2 on non existing keys in Redis >= 2.8.

Daniele Alessandri преди 12 години
родител
ревизия
ac01c1a17f
променени са 2 файла, в които са добавени 12 реда и са изтрити 8 реда
  1. 6 4
      tests/Predis/Command/KeyPreciseTimeToLiveTest.php
  2. 6 4
      tests/Predis/Command/KeyTimeToLiveTest.php

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

@@ -89,21 +89,23 @@ class KeyPreciseTimeToLiveTest extends CommandTestCase
     /**
      * @group connected
      */
-    public function testReturnsLessThanZeroOnNonExistingKeys()
+    public function testReturnsLessThanZeroOnNonExpiringKeys()
     {
         $redis = $this->getClient();
 
+        $redis->set('foo', 'bar');
         $this->assertSame(-1, $redis->pttl('foo'));
     }
 
     /**
      * @group connected
+     * @todo PTTL 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 testReturnsLessThanZeroOnNonExpiringKeys()
+    public function testReturnsLessThanZeroOnNonExistingKeys()
     {
         $redis = $this->getClient();
 
-        $redis->set('foo', 'bar');
-        $this->assertSame(-1, $redis->pttl('foo'));
+        $this->assertLessThanOrEqual(-1, $redis->pttl('foo'));
     }
 }

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

@@ -89,21 +89,23 @@ class KeyTimeToLiveTest extends CommandTestCase
     /**
      * @group connected
      */
-    public function testReturnsLessThanZeroOnNonExistingKeys()
+    public function testReturnsLessThanZeroOnNonExpiringKeys()
     {
         $redis = $this->getClient();
 
+        $redis->set('foo', 'bar');
         $this->assertSame(-1, $redis->ttl('foo'));
     }
 
     /**
      * @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 testReturnsLessThanZeroOnNonExpiringKeys()
+    public function testReturnsLessThanZeroOnNonExistingKeys()
     {
         $redis = $this->getClient();
 
-        $redis->set('foo', 'bar');
-        $this->assertSame(-1, $redis->ttl('foo'));
+        $this->assertLessThanOrEqual(-1, $redis->ttl('foo'));
     }
 }