Hey guys,
It’s been a while since I am searching for a solution to this error…Please help me if you have any Idea.
I am currently trying unit testing with Yii…I’ve installed PHPUnit and Pear successfully and can conduct Unit Tests using PhpUnit seperately.
Now…Using Yii when I test a database Connection…It gives an error.
Here’s my DbTest.php
<?php
class DbTest extends CTestCase
{
public function testConnection()
{
$this->assertNotNull(Yii::app()->db->connectionString);
}
}
and Now When I use the Command Line to get the phpunit working,It gives an error.
C:\wamp\www\Happyfriendship\trackstar\protected\tests\unit\DbTest.php:6
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
C:\wamp\www\Happyfriendship\trackstar\protected\tests>phpunit .\unit\DbTest.php
PHPUnit 3.7.29 by Sebastian Bergmann.
Configuration read from C:\wamp\www\Happyfriendship\trackstar\protected\tests\ph
punit.xml
E
Time: 48 ms, Memory: 2.75Mb
There was 1 error:
- DbTest::testConnection
CDbException: CDbConnection failed to open the DB connection.
C:\wamp\framework\db\CDbConnection.php:388
C:\wamp\framework\db\CDbConnection.php:330
C:\wamp\framework\db\CDbConnection.php:308
C:\wamp\framework\base\CModule.php:387
C:\wamp\framework\base\CModule.php:103
C:\wamp\www\Happyfriendship\trackstar\protected\tests\unit\DbTest.php:6
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
…
Now When I test the database connection manually using
>> echo Yii::app()->db->connectionString;
It again gives an error like CDbConnection failed to open the DB connection: could not find driver.
P.S
I would like to tell that I am able to generate CRUD model and can add,delete and manage using the same database credentials…So,I guess the credentials are right…I don’t know what to do.