bugfix for srem type to accept array #779 (#780)

* bugfix for srem  type to accept array #779

* add test to test SREM accept members as array type #779
This commit is contained in:
BrightQi
2022-06-28 23:23:35 +08:00
committed by GitHub
parent 2a8dd6a7f1
commit 78fd4cb998
2 changed files with 17 additions and 1 deletions
+1 -1
View File
@@ -111,7 +111,7 @@ use Predis\Response\Status;
* @method int smove(string $source, string $destination, string $member)
* @method string|array|null spop(string $key, int $count = null)
* @method string|null srandmember(string $key, int $count = null)
* @method int srem(string $key, string $member)
* @method int srem(string $key, array|string $member)
* @method array sscan(string $key, int $cursor, array $options = null)
* @method string[] sunion(array|string $keys)
* @method int sunionstore(string $destination, array|string $keys)
+16
View File
@@ -101,6 +101,22 @@ class SREM_Test extends PredisCommandTestCase
$this->assertSame(0, $redis->srem('digits', 1));
}
/**
* @group connected
* @requiresRedisVersion >= 2.4.0
*/
public function testRemovesMembersInArrayTypeFromSetVariadic(): void
{
$redis = $this->getClient();
$redis->sadd('letters', 'a', 'b', 'c', 'd');
$this->assertSame(2, $redis->srem('letters', ['b', 'd', 'z']));
$this->assertSameValues(array('a', 'c'), $redis->smembers('letters'));
$this->assertSame(0, $redis->srem('digits', [1]));
}
/**
* @group connected
*/