function UpdateTest::testSpecialColumnUpdate

Same name in other branches
  1. 8.9.x 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 136

Class

UpdateTest
Tests the update query builder.

Namespace

Drupal\KernelTests\Core\Database

Code

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

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