function UpdateTest::testSpecialColumnUpdate

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

Confirm that we can update values in a column with special name.

File

core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php, line 133

Class

UpdateTest
Tests the update query builder.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testSpecialColumnUpdate() {
    $num_updated = $this->connection
        ->update('test_special_columns')
        ->fields([
        'offset' => 'New offset value',
    ])
        ->condition('id', 1)
        ->execute();
    $this->assertIdentical($num_updated, 1, 'Updated 1 special column record.');
    $saved_value = $this->connection
        ->query('SELECT "offset" FROM {test_special_columns} WHERE id = :id', [
        ':id' => 1,
    ])
        ->fetchField();
    $this->assertIdentical($saved_value, 'New offset value', 'Updated special column name value successfully.');
}

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