You are here

function UpdateTest::testSpecialColumnUpdate in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Database/UpdateTest.php \Drupal\system\Tests\Database\UpdateTest::testSpecialColumnUpdate()

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

File

core/modules/system/src/Tests/Database/UpdateTest.php, line 152
Contains \Drupal\system\Tests\Database\UpdateTest.

Class

UpdateTest
Tests the update query builder.

Namespace

Drupal\system\Tests\Database

Code

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