PHP Unit Testing Problems With Database connection


I am trying to write database test cases to run with phpunit and am getting the following error :-

There was 1 error:

  1. DbTest::testConnection

CDbException: CDbConnection failed to open the DB connection.








Tests: 1, Assertions: 0, Errors: 1.

Additional Information:

I am running Yii on xampp under linux mint and am doing the tutorials in the book "Agile Web Application Development with Yii1.1 and PHP5.



class DbTest extends CTestCase


public function testConnection()


 &#036;this-&gt;assertNotEquals(NULL, Yii::app()-&gt;db);

My test config file is test.php


return CMap::mergeArray(







                    // uncomment the following to provide test database connection


                    'connectionString' =&gt; 'mysql:host=localhost;dbname=trackstar_dev;',

                    'emulatePrepare' =&gt; true,

                    'username' =&gt; 'root',

                    'password' =&gt; 'xxxx',

                    'charset' =&gt; 'utf8',





I have tried to implement suggestions but to no avail, can anyone help?


Try to get rid of the last [b]


[/b]in your connection string (works fine for me, but have never seen it in docs examples). Also please check out that you definitely have database [color="#1C2837"]trackstar_dev. Also, might be you need to connect to - depends on you mysql installation. Do you use localhost for any working site?[/color]