1

PHPUnit seems to be throwing exceptions on Monolog, logged errors. Is there a way around this?

I've tried several methods such as using PHP's set_error_handler function -- but that didn't work for obvious reasons (an error really isn't being thrown...)

WebControllerTest::testPostChangePasswordWithWrongCurrentPassword
PHPUnit_Framework_Exception: [2015-03-05 15:30:34] ERROR: Invalid credentials {"timeWhole":1425598234,"timeDecimal":0.0015931129455566,"type":"message:ERROR","code":49} []

/home/xxxxx/workspace/phpunit/vendor/phpunit/phpunit/src/TextUI/Command.php:152
/home/xxxxx/workspace/phpunit/vendor/phpunit/phpunit/src/TextUI/Command.php:104

Please note that, while I am indeed logging an error, I am catching it within my own application.

Also note, PHPUnit's setExpectedException does not work with PHPUnit_Framework_Exception and nor does the dot block notation:

/**
 * @expectedException PHPUnit_Framework_Exception
 */

PHPUnit also throws exceptions on audit messages.

William
  • 166
  • 4
  • 15

1 Answers1

0

Ok, finally figured this out!

It was because I was pushing a logging handler to Monolog to log errors to stderr:

$this->logger->pushHandler(new StreamHandler('php://stderr', Monolog::ERROR));
William
  • 166
  • 4
  • 15