function UpdateTest::testSimpleNullUpdate in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Database/UpdateTest.php \Drupal\system\Tests\Database\UpdateTest::testSimpleNullUpdate()
Confirms updating to NULL.
File
- core/
modules/ system/ src/ Tests/ Database/ UpdateTest.php, line 34 - Contains \Drupal\system\Tests\Database\UpdateTest.
Class
- UpdateTest
- Tests the update query builder.
Namespace
Drupal\system\Tests\DatabaseCode
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.');
}