protected function SQLiteDatabaseTrait::initDB in Drupal 7 to 8/9 Module Upgrader 8
1 call to SQLiteDatabaseTrait::initDB()
- TestBase::setUp in tests/
src/ Unit/ TestBase.php - Mocks an entire module, called foo, in a virtual file system.
File
- tests/
src/ Unit/ SQLiteDatabaseTrait.php, line 17
Class
- SQLiteDatabaseTrait
- A trait for tests that need a database.
Namespace
Drupal\Tests\drupalmoduleupgrader\UnitCode
protected function initDB() {
if (empty($this->db)) {
// In-memory databases will cease to exist as soon as the connection
// is closed, which is...convenient as hell!
$db = new \PDO('sqlite::memory:');
// Throw exceptions when things go awry.
$db
->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$this->db = new Connection($db, []);
}
}