Saturday, 24 August 2013

PHPUnit/DBUnit - createDefaultDBConnection() not accepting schema name

PHPUnit/DBUnit - createDefaultDBConnection() not accepting schema name

I am working on using PHPUnit/DBUnit to test the interaction with a
database. Thus far, I have been unable to get past
creatDefaultDBConnection(). The database has already been created in
MySQL, and I fairly confident the initial PDO connection is succeeding
since I have not received any error messages to convince me otherwise.
createDefaultDBConnection() takes the PDO handler and the schema name. I
have provided both, yet I consistently get this error:
Argument 1 passed to
PHPUnit_Extensions_Database_DefaultTester::__construct() must
implement interface PHPUnit_Extensions_Database_DB_IDatabaseConnection,
null given,
called in ../<path>/<to>/PHPUnit/Extensions/Database/TestCase.php on line
132 and
defined
Here is the test :
require_once('../includes/file/to/include.php');
class Core extends PHPUnit_Extensions_Database_TestCase {
static private $pdo = null;
public function getConnection() {
$pdo = new PDO("mysql:host=localhost;dbname=dbname", 'root', "root");
$this->createDefaultDBConnection($pdo, "dbname");
}
Any advice would be greatly appreciated.

No comments:

Post a Comment