When using PHP unit to run a unit test for code that includes a call to Yii::t an include error occurs.
I have a module called sms that contains a directory messages with a messages file called sms inside it. The Yii::t calls look like this:
echo Yii::t('smsModule.sms', 'Some message');
This works perfectly fine in web applications and in command line apps.
In a unit test, however, specifically a CDbTestCase, this code causes an error:
include(smsModule.php): failed to open stream: No such file or directory
/var/www/wijchentv-live/framework/YiiBase.php:424
/var/www/wijchentv-live/framework/YiiBase.php:424
/var/www/wijchentv-live/framework/i18n/CPhpMessageSource.php:97
/var/www/wijchentv-live/framework/i18n/CPhpMessageSource.php:114
/var/www/wijchentv-live/framework/i18n/CMessageSource.php:104
/var/www/wijchentv-live/framework/i18n/CMessageSource.php:86
/var/www/wijchentv-live/framework/YiiBase.php:581
[snip]
I’m not familiar enough with the internals of Yii to understand why this is happening. Can anyone shed some light on what is going on here and how I can work around this?
Edit The reason seems to be something to do with capitalization. If I change the Yii::t call to
echo Yii::t('SmsModule.sms', 'Some message');
it works.
Still, this is not needed for web applications and for command line applications, so there seems to be a difference between unit tests and those other two situations, which can’t be right, no?