You are here

function InsertDefaultsTest::testDefaultInsert in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Database/InsertDefaultsTest.php \Drupal\system\Tests\Database\InsertDefaultsTest::testDefaultInsert()

Tests that we can run a query that uses default values for everything.

File

core/modules/system/src/Tests/Database/InsertDefaultsTest.php, line 22
Contains \Drupal\system\Tests\Database\InsertDefaultsTest.

Class

InsertDefaultsTest
Tests the Insert query builder with default values.

Namespace

Drupal\system\Tests\Database

Code

function testDefaultInsert() {
  $query = db_insert('test')
    ->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.');
}