12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- namespace Predis\Command\Redis;
- class ZRANK_Test extends PredisCommandTestCase
- {
-
- protected function getExpectedCommand()
- {
- return 'Predis\Command\Redis\ZRANK';
- }
-
- protected function getExpectedId()
- {
- return 'ZRANK';
- }
-
- 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 testReturnsRank()
- {
- $redis = $this->getClient();
- $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f');
- $this->assertSame(0, $redis->zrank('letters', 'a'));
- $this->assertSame(1, $redis->zrank('letters', 'b'));
- $this->assertSame(4, $redis->zrank('letters', 'e'));
- $this->assertNull($redis->zrank('unknown', 'a'));
- }
-
- public function testThrowsExceptionOnWrongType()
- {
- $redis = $this->getClient();
- $redis->set('foo', 'bar');
- $redis->zrank('foo', 'bar');
- }
- }
|