123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace Predis\Command;
- class HashSetPreserveTest extends PredisCommandTestCase
- {
-
- protected function getExpectedCommand()
- {
- return 'Predis\Command\HashSetPreserve';
- }
-
- protected function getExpectedId()
- {
- return 'HSETNX';
- }
-
- public function testFilterArguments()
- {
- $arguments = array('key', 'field', 'value');
- $expected = array('key', 'field', 'value');
- $command = $this->getCommand();
- $command->setArguments($arguments);
- $this->assertSame($expected, $command->getArguments());
- }
-
- public function testParseResponse()
- {
- $command = $this->getCommand();
- $this->assertTrue($command->parseResponse(1));
- $this->assertFalse($command->parseResponse(0));
- }
-
- public function testSetsNewFieldsAndPreserversExistingOnes()
- {
- $redis = $this->getClient();
- $this->assertTrue($redis->hsetnx('metavars', 'foo', 'bar'));
- $this->assertTrue($redis->hsetnx('metavars', 'hoge', 'piyo'));
- $this->assertFalse($redis->hsetnx('metavars', 'foo', 'barbar'));
- $this->assertSame(array('bar', 'piyo'), $redis->hmget('metavars', 'foo', 'hoge'));
- }
-
- public function testThrowsExceptionOnWrongType()
- {
- $redis = $this->getClient();
- $redis->set('metavars', 'foo');
- $redis->hsetnx('metavars', 'foo', 'bar');
- }
- }
|