mirror of
https://github.com/predis/predis.git
synced 2026-10-06 11:59:30 +00:00
Make sure key prefixing is skipped when command has no arguments.
Actually this was already the case for certain commands, but some of them was left unguarded for such cases. This commit also fixes #109. The behaviour of silently skipping key prefixing when a command has no arguments may change in the future so we added explicit tests as guards for future changes. Predis\Command\Processor\KeyPrefixProcessor will continue to skip key prefixing on empty arguments, regardless.
This commit is contained in:
@@ -51,13 +51,14 @@ class KeyPrefixProcessorTest extends StandardTestCase
|
||||
public function testProcessPrefixableCommands()
|
||||
{
|
||||
$prefix = 'prefix:';
|
||||
$unprefixed = 'key';
|
||||
$expected = "$prefix$unprefixed";
|
||||
|
||||
$command = $this->getMock('Predis\Command\PrefixableCommand');
|
||||
$command->expects($this->once())
|
||||
->method('prefixKeys')
|
||||
->with($prefix);
|
||||
$command->expects($this->once())
|
||||
->method('getArguments')
|
||||
->will($this->returnValue('key'));
|
||||
|
||||
$processor = new KeyPrefixProcessor($prefix);
|
||||
|
||||
@@ -67,7 +68,23 @@ class KeyPrefixProcessorTest extends StandardTestCase
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testProcessNotPrefixableCommands()
|
||||
public function testSkipPrefixableCommandsWithNoArguments()
|
||||
{
|
||||
$prefix = 'prefix:';
|
||||
|
||||
$command = $this->getMock('Predis\Command\PrefixableCommand');
|
||||
$command->expects($this->never())
|
||||
->method('prefixKeys');
|
||||
|
||||
$processor = new KeyPrefixProcessor($prefix);
|
||||
|
||||
$processor->process($command);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testSkipNotPrefixableCommands()
|
||||
{
|
||||
$prefix = 'prefix:';
|
||||
$unprefixed = 'key';
|
||||
|
||||
Reference in New Issue
Block a user