3 namespace Drupal\KernelTests\Core\Database;
5 use Drupal\KernelTests\KernelTestBase;
8 * Base class for databases database tests.
10 * Because all database tests share the same test data, we can centralize that
13 abstract class DatabaseTestBase extends KernelTestBase {
15 public static $modules = ['database_test'];
17 protected function setUp() {
19 $this->installSchema('database_test', [
28 'test_special_columns',
31 self::addSampleData();
35 * Sets up tables for NULL handling.
37 public function ensureSampleDataNull() {
38 db_insert('test_null')
39 ->fields(['name', 'age'])
56 * Sets up our sample data.
58 public static function addSampleData() {
59 // We need the IDs, so we can't use a multi-insert here.
60 $john = db_insert('test')
68 $george = db_insert('test')
84 $paul = db_insert('test')
88 'job' => 'Songwriter',
92 db_insert('test_people')
100 db_insert('test_task')
101 ->fields(['pid', 'task', 'priority'])
129 'task' => 'found new band',
134 'task' => 'perform at superbowl',
139 db_insert('test_special_columns')
142 'offset' => 'Offset value 1',