1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace Predis\Command;
- class ZSetRankTest extends PredisCommandTestCase
- {
-
- protected function getExpectedCommand()
- {
- return 'Predis\Command\ZSetRank';
- }
-
- 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');
- }
- }
|