mirror of
https://github.com/predis/predis.git
synced 2026-08-18 15:41:58 +00:00
ab20c52115
Starting with Redis 3.0.3 the EXISTS command is variadic so that it is
possible to check for the existence of multiple keys in one request,
with the server returning the number of keys found.
This change could break codebases relying on strict comparison (===)
against a boolean value, but just doing $redis->exists('key') == TRUE
is totally fine.
85 lines
1.8 KiB
PHP
85 lines
1.8 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Predis package.
|
|
*
|
|
* (c) Daniele Alessandri <suppakilla@gmail.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Predis\Command;
|
|
|
|
/**
|
|
* @group commands
|
|
* @group realm-key
|
|
*/
|
|
class KeyRenamePreserveTest extends PredisCommandTestCase
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function getExpectedCommand()
|
|
{
|
|
return 'Predis\Command\KeyRenamePreserve';
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function getExpectedId()
|
|
{
|
|
return 'RENAMENX';
|
|
}
|
|
|
|
/**
|
|
* @group disconnected
|
|
*/
|
|
public function testFilterArguments()
|
|
{
|
|
$arguments = array('key', 'newkey');
|
|
$expected = array('key', 'newkey');
|
|
|
|
$command = $this->getCommand();
|
|
$command->setArguments($arguments);
|
|
|
|
$this->assertSame($expected, $command->getArguments());
|
|
}
|
|
|
|
/**
|
|
* @group disconnected
|
|
*/
|
|
public function testParseResponse()
|
|
{
|
|
$this->assertTrue($this->getCommand()->parseResponse(1));
|
|
$this->assertFalse($this->getCommand()->parseResponse(0));
|
|
}
|
|
|
|
/**
|
|
* @group connected
|
|
*/
|
|
public function testRenamesKeys()
|
|
{
|
|
$redis = $this->getClient();
|
|
|
|
$redis->set('foo', 'bar');
|
|
|
|
$this->assertTrue($redis->renamenx('foo', 'foofoo'));
|
|
$this->assertSame(0, $redis->exists('foo'));
|
|
$this->assertSame(1, $redis->exists('foofoo'));
|
|
}
|
|
|
|
/**
|
|
* @group connected
|
|
* @expectedException \Predis\Response\ServerException
|
|
* @expectedExceptionMessage ERR no such key
|
|
*/
|
|
public function testReturnsFalseOnNonExistingKeys()
|
|
{
|
|
$redis = $this->getClient();
|
|
|
|
$this->assertFalse($redis->renamenx('foo', 'foobar'));
|
|
}
|
|
}
|