I have a fairly crusty PHP app that I'm refactoring and adding phpunit tests for as I go. A common situation in the application is user warning messages for incorrect configuration (the application takes in a configuration file and produces images and HTML as output).
So I have a bunch of code sprinkled through the application that's like:
wm_warn("You can't make a contrast with 'none' - guessing black. [WMWARN43]\n");
where wm_warn writes to either stderr or a logfile depending on context.
How can I test these warnings with phpunit?
Importantly - this isn't a fatal error, so it's not possible (AFAIK) to replace it with an exception and use phpunit's "expected exception" feature.
Is this a use case for a wm_warn mock? Or capturing stderr? Or using a different logging method to make the testing easier (e.g. log4php)?