PrefixableCommandTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. *
  14. */
  15. class PrefixableCommandTest extends StandardTestCase
  16. {
  17. /**
  18. * @group disconnected
  19. */
  20. public function testImplementsCorrectInterface()
  21. {
  22. $command = $this->getMockForAbstractClass('Predis\Commands\PrefixableCommand');
  23. $this->assertInstanceOf('Predis\Commands\IPrefixable', $command);
  24. $this->assertInstanceOf('Predis\Commands\ICommand', $command);
  25. }
  26. /**
  27. * @group disconnected
  28. */
  29. public function testAddPrefixToFirstArgument()
  30. {
  31. $command = $this->getMockForAbstractClass('Predis\Commands\PrefixableCommand');
  32. $command->setRawArguments(array('key', 'value'));
  33. $command->prefixKeys('prefix:');
  34. $this->assertSame(array('prefix:key', 'value'), $command->getArguments());
  35. }
  36. /**
  37. * @group disconnected
  38. */
  39. public function testDoesNotBreakOnEmptyArguments()
  40. {
  41. $command = $this->getMockForAbstractClass('Predis\Commands\PrefixableCommand');
  42. $command->prefixKeys('prefix:');
  43. $this->assertEmpty($command->getArguments());
  44. }
  45. }