NullHandlerTest.php 1.2 KB

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