ListPopFirstBlockingTest.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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;
  11. /**
  12. * @group commands
  13. * @group realm-list
  14. * @todo Testing blocking pop operations against Redis using PHP is
  15. * tricky, so we will skip these kind of tests for now.
  16. */
  17. class ListPopFirstBlockingTest extends PredisCommandTestCase
  18. {
  19. /**
  20. * {@inheritdoc}
  21. */
  22. protected function getExpectedCommand()
  23. {
  24. return 'Predis\Command\ListPopFirstBlocking';
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. protected function getExpectedId()
  30. {
  31. return 'BLPOP';
  32. }
  33. /**
  34. * @group disconnected
  35. */
  36. public function testFilterArguments()
  37. {
  38. $arguments = array('key1', 'key2', 'key3', 10);
  39. $expected = array('key1', 'key2', 'key3', 10);
  40. $command = $this->getCommand();
  41. $command->setArguments($arguments);
  42. $this->assertSame($expected, $command->getArguments());
  43. }
  44. /**
  45. * @group disconnected
  46. */
  47. public function testFilterArgumentsKeysAsSingleArray()
  48. {
  49. $arguments = array(array('key1', 'key2', 'key3'), 10);
  50. $expected = array('key1', 'key2', 'key3', 10);
  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. $raw = array('key', 'value');
  61. $expected = array('key', 'value');
  62. $command = $this->getCommand();
  63. $this->assertSame($expected, $command->parseResponse($raw));
  64. }
  65. /**
  66. * @group disconnected
  67. */
  68. public function testPrefixKeys()
  69. {
  70. $arguments = array('key1', 'key2', 'key3', 10);
  71. $expected = array('prefix:key1', 'prefix:key2', 'prefix:key3', 10);
  72. $command = $this->getCommandWithArgumentsArray($arguments);
  73. $command->prefixKeys('prefix:');
  74. $this->assertSame($expected, $command->getArguments());
  75. }
  76. /**
  77. * @group disconnected
  78. */
  79. public function testPrefixKeysIgnoredOnEmptyArguments()
  80. {
  81. $command = $this->getCommand();
  82. $command->prefixKeys('prefix:');
  83. $this->assertSame(array(), $command->getArguments());
  84. }
  85. }