ListPopLastBlockingTest.php 2.4 KB

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