/** * @group redis-keys */ public function testRename() { try { $this->client->rename('foo', 'bar'); $this->fail('rename should throw exception when source does not exist'); } catch (Predis\Response\ServerException $e) { if ($e->getMessage() !== 'ERR no such key') { throw $e; } } $this->client->set('foo', 'bar'); try { $this->assertEquals('OK', $this->client->rename('foo', 'foo')); $this->fail('rename should throw exception when source and destination are the same'); } catch (Predis\Response\ServerException $e) { if ($e->getMessage() !== 'ERR source and destination objects are the same') { throw $e; } } $this->assertEquals('OK', $this->client->rename('foo', 'baz')); $this->assertTrue($this->client->exists('baz')); $this->assertFalse($this->client->exists('foo')); }