function testAddDriver() { DatabaseDriverManager::addDriver('CantRun', 'DatabaseDriverManagerTest', false); $this->assertFalse(DatabaseDriverManager::canDriverRun('CantRun')); $r = DatabaseDriverManager::addDriver('CantRun', 'DatabaseDriverManagerTest', false); $this->assertTrue($r->is(new Error('DBDRIVER_ALREADY_ADDED', 'CantRun'))); $r = DatabaseDriverManager::addDriver('InvalidClass', 'InvalidClassName', false); $this->assertTrue($r->is(new Error('DBDRIVERCLASS_NOTFOUND', 'InvalidClass', 'InvalidClassName'))); }
/** * Loads and returns a database driver. * * @since 0.4 * @return (DatabaseDriver) * @param $driverName (string) the name of the driver */ function loadDriver($driverName) { global $_DBDriverList; if (DatabaseDriverManager::canDriverRun($driverName)) { return new $_DBDriverList[$driverName]['className'](); } else { return new Error('INVALID_DATABASEDRIVER', $driverName); } }