NullHandlerTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /*
  3. * This file is part of the Monolog package.
  4. *
  5. * (c) Jordi Boggiano <j.boggiano@seld.be>
  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 Monolog\Handler;
  11. use Monolog\Logger;
  12. class NullHandlerTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testHandle()
  15. {
  16. $handler = new NullHandler();
  17. $this->assertTrue($handler->handle($this->getMessage()));
  18. }
  19. public function testHandleLowerLevelMessage()
  20. {
  21. $handler = new NullHandler(Logger::WARNING);
  22. $this->assertFalse($handler->handle($this->getMessage(Logger::DEBUG)));
  23. }
  24. public function testHandleBubbling()
  25. {
  26. $handler = new NullHandler(Logger::DEBUG, true);
  27. $this->assertFalse($handler->handle($this->getMessage()));
  28. }
  29. /**
  30. * No-op test for coverage
  31. */
  32. public function testWrite()
  33. {
  34. $handler = new NullHandler();
  35. $handler->write($this->getMessage());
  36. }
  37. protected function getMessage($level = Logger::WARNING)
  38. {
  39. return array(
  40. 'level' => $level,
  41. );
  42. }
  43. }