NullHandlerTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php declare(strict_types=1);
  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\Level;
  12. /**
  13. * @covers Monolog\Handler\NullHandler::handle
  14. */
  15. class NullHandlerTest extends \Monolog\Test\MonologTestCase
  16. {
  17. public function testHandle()
  18. {
  19. $handler = new NullHandler();
  20. $this->assertTrue($handler->handle($this->getRecord()));
  21. }
  22. public function testHandleLowerLevelRecord()
  23. {
  24. $handler = new NullHandler(Level::Warning);
  25. $this->assertFalse($handler->handle($this->getRecord(Level::Debug)));
  26. }
  27. public function testSerializeRestorePrivate()
  28. {
  29. $handler = new NullHandler(Level::Warning);
  30. self::assertFalse($handler->handle($this->getRecord(Level::Debug)));
  31. self::assertTrue($handler->handle($this->getRecord(Level::Warning)));
  32. $handler = unserialize(serialize($handler));
  33. self::assertFalse($handler->handle($this->getRecord(Level::Debug)));
  34. self::assertTrue($handler->handle($this->getRecord(Level::Warning)));
  35. }
  36. }