trait SQLiteDatabaseTrait in Drupal 7 to 8/9 Module Upgrader 8
A trait for tests that need a database.
Hierarchy
- trait \Drupal\Tests\drupalmoduleupgrader\Unit\SQLiteDatabaseTrait
File
- tests/
src/ Unit/ SQLiteDatabaseTrait.php, line 10
Namespace
Drupal\Tests\drupalmoduleupgrader\UnitView source
trait SQLiteDatabaseTrait {
/**
* @var \Drupal\Core\Database\Connection
*/
protected $db;
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, []);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SQLiteDatabaseTrait:: |
protected | property | ||
SQLiteDatabaseTrait:: |
protected | function |