Issue
If you are unit testing a model, for instance, and in that model you use CakePHP's CakeLog convenience method (perhaps testing an expected exception, etc):
CakeLog::warning('This is a warning');
Cake will not only output this at the command line during your test, it will also add the error to logs/error.log.
I need to accomplish one of two things:
- Turn off logging during unit testing
- Mock the CakeLog class or stub Model->log() (inherited from Object->log)
How does a savvy CakePHP developer accomplish one of these two things?
Solution
At the top of your test, put CakeLog::drop(logger_name);
to disable logging on the logger_name stream
Answered By - hd1 Answer Checked By - Clifford M. (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.