function DatabaseTestCase::addSampleData
Setup our sample data.
These are added using db_query(), since we're not trying to test the INSERT operations here, just populate.
2 calls to DatabaseTestCase::addSampleData()
- DatabaseSelectComplexTestCase2::setUp in modules/
simpletest/ tests/ database_test.test - Sets up a Drupal site for running functional and integration tests.
- DatabaseTestCase::setUp in modules/
simpletest/ tests/ database_test.test - Sets up a Drupal site for running functional and integration tests.
File
-
modules/
simpletest/ tests/ database_test.test, line 89
Class
- DatabaseTestCase
- Base test class for databases.
Code
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();
$ringo = 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_classtype')->fields(array(
'classname' => 'FakeRecord',
'name' => 'Kay',
'age' => 26,
'job' => 'Web Developer',
))
->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('virtual')->fields(array(
'function' => 'Function value 1',
))
->execute();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.