Yii Framework Forum: Unable To Run Unit Tests For Code That Includes Yii::t - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Unable To Run Unit Tests For Code That Includes Yii::t Rate Topic: -----

#1 User is offline   rhmtts 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 20-December 11

Posted 22 April 2013 - 08:54 AM

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?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users