123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- namespace Predis\Commands;
- use \PHPUnit_Framework_TestCase as StandardTestCase;
- class ServerObjectTest extends CommandTestCase
- {
-
- protected function getExpectedCommand()
- {
- return 'Predis\Commands\ServerObject';
- }
-
- protected function getExpectedId()
- {
- return 'OBJECT';
- }
-
- public function testFilterArguments()
- {
- $arguments = array('REFCOUNT', 'key');
- $expected = array('REFCOUNT', 'key');
- $command = $this->getCommand();
- $command->setArguments($arguments);
- $this->assertSame($expected, $command->getArguments());
- }
-
- public function testParseResponse()
- {
- $this->assertSame('ziplist', $this->getCommand()->parseResponse('ziplist'));
- }
-
- public function testObjectRefcount()
- {
- $redis = $this->getClient();
- $redis->set('foo', 'bar');
- $this->assertInternalType('integer', $redis->object('REFCOUNT', 'foo'));
- }
-
- public function testObjectIdletime()
- {
- $redis = $this->getClient();
- $redis->set('foo', 'bar');
- $this->assertInternalType('integer', $redis->object('IDLETIME', 'foo'));
- }
-
- public function testObjectEncoding()
- {
- $redis = $this->getClient();
- $redis->lpush('list:metavars', 'foo', 'bar');
- $this->assertSame('ziplist', $redis->object('ENCODING', 'list:metavars'));
- }
-
- public function testReturnsNullOnNonExistingKey()
- {
- $redis = $this->getClient();
- $this->assertNull($redis->object('REFCOUNT', 'foo'));
- $this->assertNull($redis->object('IDLETIME', 'foo'));
- $this->assertNull($redis->object('ENCODING', 'foo'));
- }
-
- public function testThrowsExceptionOnInvalidSubcommand()
- {
- $redis = $this->getClient();
- $redis->object('INVALID', 'foo');
- }
- }
|