123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?php
- namespace Predis\Command;
- class ZSetReverseRankTest extends PredisCommandTestCase
- {
-
- protected function getExpectedCommand()
- {
- return 'Predis\Command\ZSetReverseRank';
- }
-
- protected function getExpectedId()
- {
- return 'ZREVRANK';
- }
-
- public function testFilterArguments()
- {
- $arguments = array('key', 'member');
- $expected = array('key', 'member');
- $command = $this->getCommand();
- $command->setArguments($arguments);
- $this->assertSame($expected, $command->getArguments());
- }
-
- public function testParseResponse()
- {
- $this->assertSame(1, $this->getCommand()->parseResponse(1));
- }
-
- public function testPrefixKeys()
- {
- $arguments = array('key', 'member');
- $expected = array('prefix:key', 'member');
- $command = $this->getCommandWithArgumentsArray($arguments);
- $command->prefixKeys('prefix:');
- $this->assertSame($expected, $command->getArguments());
- }
-
- public function testPrefixKeysIgnoredOnEmptyArguments()
- {
- $command = $this->getCommand();
- $command->prefixKeys('prefix:');
- $this->assertSame(array(), $command->getArguments());
- }
-
- public function testReturnsRank()
- {
- $redis = $this->getClient();
- $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f');
- $this->assertSame(5, $redis->zrevrank('letters', 'a'));
- $this->assertSame(4, $redis->zrevrank('letters', 'b'));
- $this->assertSame(1, $redis->zrevrank('letters', 'e'));
- $this->assertNull($redis->zrevrank('unknown', 'a'));
- }
-
- public function testThrowsExceptionOnWrongType()
- {
- $redis = $this->getClient();
- $redis->set('foo', 'bar');
- $redis->zrevrank('foo', 'bar');
- }
- }
|