ErrorHandlerTest.php 934 B

12345678910111213141516171819202122232425262728293031
  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;
  11. use Monolog\Handler\TestHandler;
  12. class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testHandleError()
  15. {
  16. $logger = new Logger('test', array($handler = new TestHandler));
  17. $errHandler = new ErrorHandler($logger);
  18. $errHandler->registerErrorHandler(array(E_USER_NOTICE => Logger::EMERGENCY), false);
  19. trigger_error('Foo', E_USER_ERROR);
  20. $this->assertCount(1, $handler->getRecords());
  21. $this->assertTrue($handler->hasErrorRecords());
  22. trigger_error('Foo', E_USER_NOTICE);
  23. $this->assertCount(2, $handler->getRecords());
  24. $this->assertTrue($handler->hasEmergencyRecords());
  25. }
  26. }