function UpdateTest::testSimpleNullUpdate

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php \Drupal\KernelTests\Core\Database\UpdateTest::testSimpleNullUpdate()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php \Drupal\KernelTests\Core\Database\UpdateTest::testSimpleNullUpdate()
  3. 11.x core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php \Drupal\KernelTests\Core\Database\UpdateTest::testSimpleNullUpdate()

Confirms updating to NULL.

File

core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php, line 34

Class

UpdateTest
Tests the update query builder.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testSimpleNullUpdate() : void {
    $this->ensureSampleDataNull();
    $num_updated = $this->connection
        ->update('test_null')
        ->fields([
        'age' => NULL,
    ])
        ->condition('name', 'Kermit')
        ->execute();
    $this->assertSame(1, $num_updated, 'Updated 1 record.');
    $saved_age = $this->connection
        ->query('SELECT [age] FROM {test_null} WHERE [name] = :name', [
        ':name' => 'Kermit',
    ])
        ->fetchField();
    $this->assertNull($saved_age, 'Updated name successfully.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.