You are here

function UpdateTest::testSimpleUpdate 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::testSimpleUpdate()

Confirms that we can update a single record successfully.

File

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

Class

UpdateTest
Tests the update query builder.

Namespace

Drupal\system\Tests\Database

Code

function testSimpleUpdate() {
  $num_updated = db_update('test')
    ->fields(array(
    'name' => 'Tiffany',
  ))
    ->condition('id', 1)
    ->execute();
  $this
    ->assertIdentical($num_updated, 1, 'Updated 1 record.');
  $saved_name = db_query('SELECT name FROM {test} WHERE id = :id', array(
    ':id' => 1,
  ))
    ->fetchField();
  $this
    ->assertIdentical($saved_name, 'Tiffany', 'Updated name successfully.');
}