You are here

public function InsertDefaultsTest::testDefaultInsert in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php \Drupal\KernelTests\Core\Database\InsertDefaultsTest::testDefaultInsert()

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

File

core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php, line 17

Class

InsertDefaultsTest
Tests the Insert query builder with default values.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testDefaultInsert() {
  $query = $this->connection
    ->insert('test')
    ->useDefaults([
    'job',
  ]);
  $id = $query
    ->execute();
  $schema = drupal_get_module_schema('database_test', 'test');
  $job = $this->connection
    ->query('SELECT job FROM {test} WHERE id = :id', [
    ':id' => $id,
  ])
    ->fetchField();
  $this
    ->assertEqual($job, $schema['fields']['job']['default'], 'Default field value is set.');
}