ExceptionsOptionTest.php 1.8 KB

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