StringSubstrTest.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. * SUBSTR is actually the old name of GETRANGE in version of Redis <= 2.0.
  13. * This command should be considered obsolete and we will perform any kind
  14. * of tests against a Redis server for this one.
  15. *
  16. * @group commands
  17. * @group realm-string
  18. */
  19. class StringSubstrTest extends PredisCommandTestCase
  20. {
  21. /**
  22. * {@inheritdoc}
  23. */
  24. protected function getExpectedCommand()
  25. {
  26. return 'Predis\Command\StringSubstr';
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. protected function getExpectedId()
  32. {
  33. return 'SUBSTR';
  34. }
  35. /**
  36. * @group disconnected
  37. */
  38. public function testFilterArguments()
  39. {
  40. $arguments = array('key', 5, 10);
  41. $expected = array('key', 5, 10);
  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. $this->assertSame('substring',$this->getCommand()->parseResponse('substring'));
  52. }
  53. /**
  54. * @group disconnected
  55. */
  56. public function testPrefixKeys()
  57. {
  58. $arguments = array('key', 5, 10);
  59. $expected = array('prefix:key', 5, 10);
  60. $command = $this->getCommandWithArgumentsArray($arguments);
  61. $command->prefixKeys('prefix:');
  62. $this->assertSame($expected, $command->getArguments());
  63. }
  64. /**
  65. * @group disconnected
  66. */
  67. public function testPrefixKeysIgnoredOnEmptyArguments()
  68. {
  69. $command = $this->getCommand();
  70. $command->prefixKeys('prefix:');
  71. $this->assertSame(array(), $command->getArguments());
  72. }
  73. }