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