I’m working on a site with yii, which is very nice and everything is fine except the logging doesn’t work when I run my test cases. I’m basically logging values inside my model classes which works when I run the application in the browser fine. My tests are supported by a bootstrapper and the models are run inside unit tests as usual.
The unit tests run fine, but they don’t add anything to the logs. Is there anything I need to do to like activate the logger in the bootstrapper?
Looks like your logger is monitoring the category "system.*" and the log you are testing with specifies "bobcom" as the category to log to. Since they do not match you will not the event. See the document here http://www.yiiframework.com/doc/guide/topics.logging
To see the tracing done by other parts of Yii, i.e., the Yii::trace calls, (for me the CActiveRecord SQL calls were particularly helpful) in unit tests, one needs to enable DEBUG mode in the unit tests, just as it is enabled in the index.php file.
I copied this fragment from index.php:
defined('YII_DEBUG') or define('YII_DEBUG',true);
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 1);
to protected/tests/bootstrap.php
Then I can see the SQL generated by my overridden CActiveRecord methods.