PFMERGE_Test.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /*
  3. * This file is part of the Predis package.
  4. *
  5. * (c) Daniele Alessandri <suppakilla@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Predis\Command\Redis;
  11. /**
  12. * @group commands
  13. * @group realm-hyperloglog
  14. *
  15. * @todo Add integration tests depending on the minor redis version.
  16. */
  17. class PFMERGE_Test extends PredisCommandTestCase
  18. {
  19. /**
  20. * {@inheritdoc}
  21. */
  22. protected function getExpectedCommand()
  23. {
  24. return 'Predis\Command\Redis\PFMERGE';
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. protected function getExpectedId()
  30. {
  31. return 'PFMERGE';
  32. }
  33. /**
  34. * @group disconnected
  35. */
  36. public function testFilterArguments()
  37. {
  38. $arguments = array('key:1', 'key:2', 'key:3');
  39. $expected = array('key:1', 'key:2', 'key:3');
  40. $command = $this->getCommand();
  41. $command->setArguments($arguments);
  42. $this->assertSame($expected, $command->getArguments());
  43. }
  44. /**
  45. * @group disconnected
  46. */
  47. public function testFilterArgumentsFieldsAsSingleArray()
  48. {
  49. $arguments = array(array('key:1', 'key:2', 'key:3'));
  50. $expected = array('key:1', 'key:2', 'key:3');
  51. $command = $this->getCommand();
  52. $command->setArguments($arguments);
  53. $this->assertSame($expected, $command->getArguments());
  54. }
  55. /**
  56. * @group disconnected
  57. */
  58. public function testParseResponse()
  59. {
  60. $this->assertSame('OK', $this->getCommand()->parseResponse('OK'));
  61. }
  62. /**
  63. * @group connected
  64. * @requiresRedisVersion >= 2.8.9
  65. * @expectedException \Predis\Response\ServerException
  66. * @expectedExceptionMessage Operation against a key holding the wrong kind of value
  67. */
  68. public function testThrowsExceptionOnWrongType()
  69. {
  70. $redis = $this->getClient();
  71. $redis->pfadd('metavars:1', 'foo', 'hoge');
  72. $redis->lpush('metavars:2', 'foofoo');
  73. $redis->pfmerge('metavars:1', 'metavars:2');
  74. }
  75. }