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. 10 core/tests/Drupal/KernelTests/Core/Database/InsertTest.php \Drupal\KernelTests\Core\Database\InsertTest::testSpecialColumnInsert()
  3. 11.x 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 200

Class

InsertTest
Tests the insert builder.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testSpecialColumnInsert() {
    $this->connection
        ->insert('test_special_columns')
        ->fields([
        'id' => 2,
        'offset' => 'Offset value 2',
        'function' => 'foobar',
    ])
        ->execute();
    $result = $this->connection
        ->select('test_special_columns')
        ->fields('test_special_columns', [
        'offset',
        'function',
    ])
        ->condition('test_special_columns.function', 'foobar')
        ->execute();
    $record = $result->fetch();
    $this->assertSame('Offset value 2', $record->offset);
    $this->assertSame('foobar', $record->function);
}

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