KeyKeysV12xTest.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. * We only perform disconnected tests for this commands because
  13. * it is too old (Redis v1.2) and expects a different response
  14. * format.
  15. *
  16. * @group commands
  17. * @group realm-key
  18. */
  19. class KeyKeysV12xTest extends PredisCommandTestCase
  20. {
  21. /**
  22. * {@inheritdoc}
  23. */
  24. protected function getExpectedCommand()
  25. {
  26. return 'Predis\Command\KeyKeysV12x';
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. protected function getExpectedId()
  32. {
  33. return 'KEYS';
  34. }
  35. /**
  36. * @group disconnected
  37. */
  38. public function testFilterArguments()
  39. {
  40. $arguments = array('pattern:*');
  41. $expected = array('pattern:*');
  42. $command = $this->getCommand();
  43. $command->setArguments($arguments);
  44. $this->assertSame($expected, $command->getArguments());
  45. }
  46. /**
  47. * @group disconnected
  48. */
  49. public function testParseResponse()
  50. {
  51. $raw = 'key1 key2 key3';
  52. $parsed = array('key1', 'key2', 'key3');
  53. $this->assertSame($parsed, $this->getCommand()->parseResponse($raw));
  54. }
  55. /**
  56. * @group disconnected
  57. */
  58. public function testPrefixKeys()
  59. {
  60. $arguments = array('pattern');
  61. $expected = array('prefix:pattern');
  62. $command = $this->getCommandWithArgumentsArray($arguments);
  63. $command->prefixKeys('prefix:');
  64. $this->assertSame($expected, $command->getArguments());
  65. }
  66. /**
  67. * @group disconnected
  68. */
  69. public function testPrefixKeysIgnoredOnEmptyArguments()
  70. {
  71. $command = $this->getCommand();
  72. $command->prefixKeys('prefix:');
  73. $this->assertSame(array(), $command->getArguments());
  74. }
  75. }