GroupHandlerTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. class ForwarderHandlerTest extends TestCase
  14. {
  15. public function testHandleForward()
  16. {
  17. $testHandlers = array(new TestHandler(), new TestHandler());
  18. $handler = new ForwarderHandler($testHandlers);
  19. $handler->handle($this->getRecord(Logger::DEBUG));
  20. $handler->handle($this->getRecord(Logger::INFO));
  21. foreach ($testHandlers as $test) {
  22. $this->assertTrue($test->hasDebugRecords());
  23. $this->assertTrue($test->hasInfoRecords());
  24. $this->assertTrue(count($test->getRecords()) === 2);
  25. }
  26. }
  27. public function testHandleBatchForward()
  28. {
  29. $testHandlers = array(new TestHandler(), new TestHandler());
  30. $handler = new ForwarderHandler($testHandlers);
  31. $handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO)));
  32. foreach ($testHandlers as $test) {
  33. $this->assertTrue($test->hasDebugRecords());
  34. $this->assertTrue($test->hasInfoRecords());
  35. $this->assertTrue(count($test->getRecords()) === 2);
  36. }
  37. }
  38. }