public function UpdateTest::testSimpleUpdate in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php \Drupal\KernelTests\Core\Database\UpdateTest::testSimpleUpdate()
Confirms that we can update a single record successfully.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Database/ UpdateTest.php, line 18
Class
- UpdateTest
- Tests the update query builder.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testSimpleUpdate() {
$num_updated = $this->connection
->update('test')
->fields([
'name' => 'Tiffany',
])
->condition('id', 1)
->execute();
$this
->assertSame(1, $num_updated, 'Updated 1 record.');
$saved_name = $this->connection
->query('SELECT [name] FROM {test} WHERE [id] = :id', [
':id' => 1,
])
->fetchField();
$this
->assertSame('Tiffany', $saved_name, 'Updated name successfully.');
}