Hi i have installed yii and i am doing the Yii book "Agile with Yii 1.1 and PHP5: The TrackStar Application" and setting up the phpunit and selenium tests.
I manage to setup a database and get and set data throught the models however when trying to test the database it doesnt work?!
DbTest.php
<?php
class DbTest extends CTestCase
{
public function testConnection()
{
$this->assertNotEquals(NULL, Yii::app()->db);
}
}
this gives me:
DbTest::testConnection()
CDbException: CDbConnection failed to open the DB connection.
...../framework/db/CDbConnection.php:275
...../framework/db/CDbConnection.php:242
...../framework/db/CDbConnection.php:221
...../framework/base/CModule.php:363
...../framework/base/CModule.php:86
...../YII/trackstar/protected/tests/unit/DbTest.php:10
i have also setup the bootstrap and the xml configuration to use the relevant files in the trackstar application.
this is my main.php config
/*
'db'=>array(
'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
),
*/
// uncomment the following to use a MySQL database
'db'=>array(
//'class'=>'CDbConnection',
'connectionString' => 'mysql:host=localhost;dbname=yii_trackstar_dev',
'emulatePrepare' => true,
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
),
note that i have disabled the sqlite. and also note that if i desable mysql and use sqlite the test runs with success…this is making me crazy since the application is clearly working with CRUD its only the tests that are failing…
please help me with this.