static function DatabaseTestBase::addSampleData in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Database/DatabaseTestBase.php \Drupal\system\Tests\Database\DatabaseTestBase::addSampleData()
Sets up our sample data.
2 calls to DatabaseTestBase::addSampleData()
- DatabaseTestBase::setUp in core/
modules/ system/ src/ Tests/ Database/ DatabaseTestBase.php - Performs setup tasks before each individual test method is run.
- DatabaseWebTestBase::setUp in core/
modules/ system/ src/ Tests/ Database/ DatabaseWebTestBase.php - Sets up a Drupal site for running functional and integration tests.
File
- core/
modules/ system/ src/ Tests/ Database/ DatabaseTestBase.php, line 63 - Contains \Drupal\system\Tests\Database\DatabaseTestBase.
Class
- DatabaseTestBase
- Base class for databases database tests.
Namespace
Drupal\system\Tests\DatabaseCode
static function addSampleData() {
// We need the IDs, so we can't use a multi-insert here.
$john = db_insert('test')
->fields(array(
'name' => 'John',
'age' => 25,
'job' => 'Singer',
))
->execute();
$george = db_insert('test')
->fields(array(
'name' => 'George',
'age' => 27,
'job' => 'Singer',
))
->execute();
db_insert('test')
->fields(array(
'name' => 'Ringo',
'age' => 28,
'job' => 'Drummer',
))
->execute();
$paul = db_insert('test')
->fields(array(
'name' => 'Paul',
'age' => 26,
'job' => 'Songwriter',
))
->execute();
db_insert('test_people')
->fields(array(
'name' => 'Meredith',
'age' => 30,
'job' => 'Speaker',
))
->execute();
db_insert('test_task')
->fields(array(
'pid',
'task',
'priority',
))
->values(array(
'pid' => $john,
'task' => 'eat',
'priority' => 3,
))
->values(array(
'pid' => $john,
'task' => 'sleep',
'priority' => 4,
))
->values(array(
'pid' => $john,
'task' => 'code',
'priority' => 1,
))
->values(array(
'pid' => $george,
'task' => 'sing',
'priority' => 2,
))
->values(array(
'pid' => $george,
'task' => 'sleep',
'priority' => 2,
))
->values(array(
'pid' => $paul,
'task' => 'found new band',
'priority' => 1,
))
->values(array(
'pid' => $paul,
'task' => 'perform at superbowl',
'priority' => 3,
))
->execute();
db_insert('test_special_columns')
->fields(array(
'id' => 1,
'offset' => 'Offset value 1',
))
->execute();
}