function InsertDefaultsTest::testDefaultInsertWithFields in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Database/InsertDefaultsTest.php \Drupal\system\Tests\Database\InsertDefaultsTest::testDefaultInsertWithFields()
Tests that we can insert fields with values and defaults in the same query.
File
- core/
modules/ system/ src/ Tests/ Database/ InsertDefaultsTest.php, line 53 - Contains \Drupal\system\Tests\Database\InsertDefaultsTest.
Class
- InsertDefaultsTest
- Tests the Insert query builder with default values.
Namespace
Drupal\system\Tests\DatabaseCode
function testDefaultInsertWithFields() {
$query = db_insert('test')
->fields(array(
'name' => 'Bob',
))
->useDefaults(array(
'job',
));
$id = $query
->execute();
$schema = drupal_get_module_schema('database_test', 'test');
$job = db_query('SELECT job FROM {test} WHERE id = :id', array(
':id' => $id,
))
->fetchField();
$this
->assertEqual($job, $schema['fields']['job']['default'], 'Default field value is set.');
}