You are here

function DatabaseUpdateTestCase::testSimpleNullUpdate in Drupal 7

Confirm updating to NULL.

File

modules/simpletest/tests/database_test.test, line 791

Class

DatabaseUpdateTestCase
Update builder tests.

Code

function testSimpleNullUpdate() {
  $this
    ->ensureSampleDataNull();
  $num_updated = db_update('test_null')
    ->fields(array(
    'age' => NULL,
  ))
    ->condition('name', 'Kermit')
    ->execute();
  $this
    ->assertIdentical($num_updated, 1, 'Updated 1 record.');
  $saved_age = db_query('SELECT age FROM {test_null} WHERE name = :name', array(
    ':name' => 'Kermit',
  ))
    ->fetchField();
  $this
    ->assertNull($saved_age, 'Updated name successfully.');
}