PrefixOptionTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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\Configuration;
  11. use PredisTestCase;
  12. /**
  13. *
  14. */
  15. class PrefixOptionTest extends PredisTestCase
  16. {
  17. /**
  18. * @group disconnected
  19. */
  20. public function testDefaultOptionValue()
  21. {
  22. $option = new PrefixOption();
  23. $options = $this->getMock('Predis\Configuration\OptionsInterface');
  24. $this->assertNull($option->getDefault($options));
  25. }
  26. /**
  27. * @group disconnected
  28. */
  29. public function testAcceptsStringAndReturnsCommandProcessor()
  30. {
  31. $option = new PrefixOption();
  32. $options = $this->getMock('Predis\Configuration\OptionsInterface');
  33. $return = $option->filter($options, $value = 'prefix:');
  34. $this->assertInstanceOf('Predis\Command\Processor\ProcessorInterface', $return);
  35. $this->assertInstanceOf('Predis\Command\Processor\KeyPrefixProcessor', $return);
  36. $this->assertSame($value, $return->getPrefix());
  37. }
  38. /**
  39. * @group disconnected
  40. */
  41. public function testAcceptsCommandProcessorInstance()
  42. {
  43. $option = new PrefixOption();
  44. $options = $this->getMock('Predis\Configuration\OptionsInterface');
  45. $processor = $this->getMock('Predis\Command\Processor\ProcessorInterface');
  46. $return = $option->filter($options, $processor);
  47. $this->assertSame($processor, $return);
  48. }
  49. }