You are here

public function UpdateTest::testSpecialColumnUpdate in Drupal 9

Same name and namespace in other branches
  1. 8 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);
}