ClientPrefixTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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\Options;
  11. use \PHPUnit_Framework_TestCase as StandardTestCase;
  12. /**
  13. *
  14. */
  15. class ClientPrefixTest extends StandardTestCase
  16. {
  17. /**
  18. * @group disconnected
  19. */
  20. public function testValidationReturnsCommandProcessor()
  21. {
  22. $value = 'prefix:';
  23. $options = $this->getMock('Predis\Options\IClientOptions');
  24. $option = new ClientPrefix();
  25. $return = $option->filter($options, $value);
  26. $this->assertInstanceOf('Predis\Commands\Processors\ICommandProcessor', $return);
  27. $this->assertInstanceOf('Predis\Commands\Processors\KeyPrefixProcessor', $return);
  28. $this->assertEquals($value, $return->getPrefix());
  29. }
  30. /**
  31. * @group disconnected
  32. */
  33. public function testDefaultReturnsNull()
  34. {
  35. $options = $this->getMock('Predis\Options\IClientOptions');
  36. $option = new ClientPrefix();
  37. $this->assertNull($option->getDefault($options));
  38. }
  39. /**
  40. * @group disconnected
  41. */
  42. public function testInvokeReturnsCommandProcessorOrNull()
  43. {
  44. $options = $this->getMock('Predis\Options\IClientOptions');
  45. $option = new ClientPrefix();
  46. $this->assertInstanceOf('Predis\Commands\Processors\ICommandProcessor', $option($options, 'prefix:'));
  47. $this->assertNull($option($options, null));
  48. }
  49. }