123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace Predis\Command;
- class HashExistsTest extends PredisCommandTestCase
- {
-
- protected function getExpectedCommand()
- {
- return 'Predis\Command\HashExists';
- }
-
- protected function getExpectedId()
- {
- return 'HEXISTS';
- }
-
- public function testFilterArguments()
- {
- $arguments = array('key', 'field');
- $expected = array('key', 'field');
- $command = $this->getCommand();
- $command->setArguments($arguments);
- $this->assertSame($expected, $command->getArguments());
- }
-
- public function testParseResponse()
- {
- $command = $this->getCommand();
- $this->assertFalse($command->parseResponse(0));
- $this->assertTrue($command->parseResponse(1));
- }
-
- public function testReturnsExistenceOfSpecifiedField()
- {
- $redis = $this->getClient();
- $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo');
- $this->assertTrue($redis->hexists('metavars', 'foo'));
- $this->assertFalse($redis->hexists('metavars', 'lol'));
- $this->assertFalse($redis->hexists('unknown', 'foo'));
- }
-
- public function testThrowsExceptionOnWrongType()
- {
- $redis = $this->getClient();
- $redis->set('foo', 'bar');
- $redis->hexists('foo', 'bar');
- }
- }
|