StringSubstrTest.php 1.7 KB

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