getCommand(); $command->setArguments($arguments); $this->assertSame($expected, $command->getArguments()); } /** * @group disconnected */ public function testFilterArgumentsIndicesAsSingleArray(): void { $arguments = ['key', [0, 1, 2]]; $expected = ['key', 0, 1, 2]; $command = $this->getCommand(); $command->setArguments($arguments); $this->assertSame($expected, $command->getArguments()); } /** * @group disconnected */ public function testParseResponse(): void { $this->assertSame(2, $this->getCommand()->parseResponse(2)); } /** * @group disconnected */ public function testPrefixKeys(): void { /** @var PrefixableCommand $command */ $command = $this->getCommand(); $actualArguments = ['arg1', 0, 1]; $prefix = 'prefix:'; $expectedArguments = ['prefix:arg1', 0, 1]; $command->setArguments($actualArguments); $command->prefixKeys($prefix); $this->assertSame($expectedArguments, $command->getArguments()); } /** * @group connected * @requiresRedisVersion >= 8.8.0 */ public function testReturnsNumberOfDeletedElements(): void { $redis = $this->getClient(); $redis->arset('arr', 0, 'a', 'b', 'c', 'd'); $this->assertSame(2, $redis->ardel('arr', 0, 2)); } /** * @group connected * @requiresRedisVersion >= 8.8.0 */ public function testReturnsZeroOnNonExistingIndex(): void { $redis = $this->getClient(); $redis->arset('arr', 0, 'a'); $this->assertSame(0, $redis->ardel('arr', 100, 200)); } /** * @group connected * @requiresRedisVersion >= 8.8.0 */ public function testDeletesElementsResp3(): void { $redis = $this->getResp3Client(); $redis->arset('arr', 0, 'a', 'b', 'c'); $this->assertSame(2, $redis->ardel('arr', 0, 1)); } /** * @group connected * @requiresRedisVersion >= 8.8.0 */ public function testThrowsExceptionOnWrongType(): void { $this->expectException('Predis\Response\ServerException'); $this->expectExceptionMessage('Operation against a key holding the wrong kind of value'); $redis = $this->getClient(); $redis->set('foo', 'bar'); $redis->ardel('foo', 0); } }