ListPopLastBlockingTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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\Commands;
  11. use \PHPUnit_Framework_TestCase as StandardTestCase;
  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 CommandTestCase
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. protected function getExpectedCommand()
  24. {
  25. return 'Predis\Commands\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. }