getCommand(); $command->setArguments($arguments); $this->assertSame($expected, $command->getArguments()); } /** * @group disconnected */ public function testParseResponse(): void { $this->assertSame(3, $this->getCommand()->parseResponse(3)); } /** * @group disconnected */ public function testPrefixKeys(): void { /** @var PrefixableCommand $command */ $command = $this->getCommand(); $actualArguments = ['arg1']; $prefix = 'prefix:'; $expectedArguments = ['prefix:arg1']; $command->setArguments($actualArguments); $command->prefixKeys($prefix); $this->assertSame($expectedArguments, $command->getArguments()); } /** * @group connected * @requiresRedisVersion >= 8.8.0 */ public function testReturnsCountOfNonEmptyElements(): void { $redis = $this->getClient(); $redis->arset('arr', 0, 'a', 'b', 'c'); $this->assertSame(3, $redis->arcount('arr')); } /** * @group connected * @requiresRedisVersion >= 8.8.0 */ public function testReturnsZeroWhenKeyDoesNotExist(): void { $redis = $this->getClient(); $this->assertSame(0, $redis->arcount('nonexistent')); } /** * @group connected * @requiresRedisVersion >= 8.8.0 */ public function testReturnsCountResp3(): void { $redis = $this->getResp3Client(); $redis->arset('arr', 0, 'a', 'b', 'c'); $this->assertSame(3, $redis->arcount('arr')); $this->assertSame(0, $redis->arcount('nonexistent')); } /** * @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->arcount('foo'); } }