function InsertTest::testSpecialColumnInsert

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/InsertTest.php \Drupal\KernelTests\Core\Database\InsertTest::testSpecialColumnInsert()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Database/InsertTest.php \Drupal\KernelTests\Core\Database\InsertTest::testSpecialColumnInsert()
  3. 10 core/tests/Drupal/KernelTests/Core/Database/InsertTest.php \Drupal\KernelTests\Core\Database\InsertTest::testSpecialColumnInsert()

Tests that we can INSERT INTO a special named column.

File

core/tests/Drupal/KernelTests/Core/Database/InsertTest.php, line 204

Class

InsertTest
Tests the insert builder.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testSpecialColumnInsert() : void {
    $this->connection
        ->insert('select')
        ->fields([
        'id' => 2,
        'update' => 'Update value 2',
    ])
        ->execute();
    $saved_value = $this->connection
        ->query('SELECT [update] FROM {select} WHERE [id] = :id', [
        ':id' => 2,
    ])
        ->fetchField();
    $this->assertEquals('Update value 2', $saved_value);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.