Well, the unit test will be loading the test.php config file. Do you happen to have a different ‘db’ component specified in this file (/protected/config/test.php)?
One thing to try is to load the interactive shell using the test.php config and then attempt to see what Yii::app()->db is:
From within your application’s /protected directory issue:
$ ./yiic shell config/test.php
Which should run the shell:
Yii Interactive Tool v1.1 (based on Yii v1.1.2)
Please type 'help' for help. Type 'exit' to quit.
>>
Then try:
>> echo isset(Yii::app()->db);
and see if you get back a 1 (which means everything is good) or if this also generates the DBException.
Actually i only have the db component in the ‘main.php’, but i dont think it’s the problem, because when i replace Postgres with MySQL, the test passes.
I’ve put the db component in ‘test.php’, but the test still failed.
When i run
>> echo isset(Yii::app()->db);
it throws Exception :
exception 'CDbException' with message 'CDbConnection failed to open the DB connection: could not find driver' in /Applications/MAMP/Library/yii/framework/db/CDbConnection.php:272