Browse Source

[tests] Test count argument for SPOP in Redis 3.2.

Daniele Alessandri 8 years ago
parent
commit
1e521b56cd
1 changed files with 18 additions and 2 deletions
  1. 18 2
      tests/Predis/Command/SetPopTest.php

+ 18 - 2
tests/Predis/Command/SetPopTest.php

@@ -38,8 +38,8 @@ class SetPopTest extends PredisCommandTestCase
      */
     public function testFilterArguments()
     {
-        $arguments = array('key');
-        $expected = array('key');
+        $arguments = array('key', 2);
+        $expected = array('key', 2);
 
         $command = $this->getCommand();
         $command->setArguments($arguments);
@@ -70,6 +70,22 @@ class SetPopTest extends PredisCommandTestCase
         $this->assertNull($redis->spop('letters'));
     }
 
+    /**
+     * @group connected
+     * @requiresRedisVersion >= 3.2.0
+     */
+    public function testPopsMoreRandomMembersFromSet()
+    {
+        $redis = $this->getClient();
+
+        $redis->sadd('letters', 'a', 'b', 'c');
+
+        $this->assertSameValues(array('a', 'b', 'c'), $redis->spop('letters', 3));
+        $this->assertEmpty($redis->spop('letters', 3));
+
+        $this->assertNull($redis->spop('letters'));
+    }
+
     /**
      * @group connected
      * @expectedException \Predis\Response\ServerException