Suppose there is a logging function
class Logger { public function log($message) { fwrite(STDERR, json_encode([time() => $message])); } }
There is control over $message
, of course, but not very much over time()
.
How can I use PHPUnit to test that a string matches the pattern in STDERR? (and if you immediately check for the correct JSON, then it's generally great)
{%i:"error"}