public function UpdateTest::testMultiUpdate in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php \Drupal\KernelTests\Core\Database\UpdateTest::testMultiUpdate()
Confirms that we can update multiple records successfully.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Database/ UpdateTest.php, line 47
Class
- UpdateTest
- Tests the update query builder.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testMultiUpdate() {
$num_updated = $this->connection
->update('test')
->fields([
'job' => 'Musician',
])
->condition('job', 'Singer')
->execute();
$this
->assertSame(2, $num_updated, 'Updated 2 records.');
$num_matches = $this->connection
->query('SELECT COUNT(*) FROM {test} WHERE [job] = :job', [
':job' => 'Musician',
])
->fetchField();
$this
->assertSame('2', $num_matches, 'Updated fields successfully.');
}