ExceptionsTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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\Option;
  11. use PredisTestCase;
  12. /**
  13. *
  14. */
  15. class ExceptionsTest extends PredisTestCase
  16. {
  17. /**
  18. * @group disconnected
  19. */
  20. public function testDefaultOptionValue()
  21. {
  22. $option = new Exceptions();
  23. $options = $this->getMock('Predis\Configuration\OptionsInterface');
  24. $this->assertTrue($option->getDefault($options));
  25. }
  26. /**
  27. * @group disconnected
  28. */
  29. public function testAcceptsDifferentValuesAndFiltersThemAsBooleans()
  30. {
  31. $option = new Exceptions();
  32. $options = $this->getMock('Predis\Configuration\OptionsInterface');
  33. $this->assertFalse($option->filter($options, null));
  34. $this->assertTrue($option->filter($options, true));
  35. $this->assertFalse($option->filter($options, false));
  36. $this->assertTrue($option->filter($options, 1));
  37. $this->assertFalse($option->filter($options, 0));
  38. $this->assertTrue($option->filter($options, 'true'));
  39. $this->assertFalse($option->filter($options, 'false'));
  40. $this->assertTrue($option->filter($options, 'on'));
  41. $this->assertFalse($option->filter($options, 'off'));
  42. }
  43. /**
  44. * @group disconnected
  45. */
  46. public function testReturnsFalesOnValuesNotParsableAsBooleans()
  47. {
  48. $option = new Exceptions();
  49. $options = $this->getMock('Predis\Configuration\OptionsInterface');
  50. $this->assertFalse($option->filter($options, new \stdClass()));
  51. $this->assertFalse($option->filter($options, 'invalid'));
  52. }
  53. }