Fix prefixes for LMOVE and BLMOVE (#1455)

Co-authored-by: Till Krüss <tillkruss@users.noreply.github.com>
This commit is contained in:
Markus Reinhold
2024-05-02 17:55:20 +02:00
committed by GitHub
parent 4dc72458e8
commit cbef71090b
2 changed files with 60 additions and 0 deletions
@@ -120,6 +120,37 @@ class KeyPrefixProcessorTest extends PredisTestCase
$this->assertEmpty($command->getArguments());
}
/**
* @group disconnected
*/
public function testPrefixFirstTwo(): void
{
$arguments = ['1st', '2nd', '3rd', '4th'];
$expected = ['prefix:1st', 'prefix:2nd', '3rd', '4th'];
$command = $this->getMockForAbstractClass('Predis\Command\Command');
$command->setRawArguments($arguments);
KeyPrefixProcessor::firstTwo($command, 'prefix:');
$this->assertSame($expected, $command->getArguments());
// One argument
$arguments = ['1st'];
$expected = ['prefix:1st'];
$command = $this->getMockForAbstractClass('Predis\Command\Command');
$command->setRawArguments($arguments);
KeyPrefixProcessor::firstTwo($command, 'prefix:');
$this->assertSame($expected, $command->getArguments());
// Empty arguments
$command = $this->getMockForAbstractClass('Predis\Command\Command');
KeyPrefixProcessor::firstTwo($command, 'prefix:');
$this->assertEmpty($command->getArguments());
}
/**
* @group disconnected
*/
@@ -978,6 +1009,14 @@ class KeyPrefixProcessorTest extends PredisTestCase
['key'],
['prefix:key'],
],
['LMOVE',
['key:source', 'key:destination', 'left', 'right'],
['prefix:key:source', 'prefix:key:destination', 'left', 'right'],
],
['BLMOVE',
['key:source', 'key:destination', 'left', 'right', 10],
['prefix:key:source', 'prefix:key:destination', 'left', 'right', 10],
],
/* ---------------- Redis 7.0 ---------------- */
['EXPIRETIME',
['key'],