AbstractProcessingHandlerTest.php 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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\TestCase;
  12. use Monolog\Logger;
  13. use Monolog\Processor\WebProcessor;
  14. class AbstractProcessingHandlerTest extends TestCase
  15. {
  16. /**
  17. * @covers Monolog\Handler\AbstractProcessingHandler::handle
  18. */
  19. public function testHandleLowerLevelMessage()
  20. {
  21. $handler = new TestHandler(Logger::WARNING, true);
  22. $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
  23. }
  24. /**
  25. * @covers Monolog\Handler\AbstractProcessingHandler::handle
  26. */
  27. public function testHandleBubbling()
  28. {
  29. $handler = new TestHandler(Logger::DEBUG, true);
  30. $this->assertFalse($handler->handle($this->getRecord()));
  31. }
  32. /**
  33. * @covers Monolog\Handler\AbstractProcessingHandler::handle
  34. */
  35. public function testHandleNotBubbling()
  36. {
  37. $handler = new TestHandler(Logger::DEBUG, false);
  38. $this->assertTrue($handler->handle($this->getRecord()));
  39. }
  40. /**
  41. * @covers Monolog\Handler\AbstractProcessingHandler::handle
  42. */
  43. public function testHandleIsFalseWhenNotHandled()
  44. {
  45. $handler = new TestHandler(Logger::WARNING, false);
  46. $this->assertTrue($handler->handle($this->getRecord()));
  47. $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
  48. }
  49. /**
  50. * @covers Monolog\Handler\AbstractProcessingHandler::processRecord
  51. */
  52. public function testProcessRecord()
  53. {
  54. $handler = new TestHandler();
  55. $handler->pushProcessor(new WebProcessor(array(
  56. 'REQUEST_URI' => '',
  57. 'REQUEST_METHOD' => '',
  58. 'REMOTE_ADDR' => '',
  59. )));
  60. $handler->handle($this->getRecord());
  61. list($record) = $handler->getRecords();
  62. $this->assertEquals(3, count($record['extra']));
  63. }
  64. }