function UpdateTest::testSimpleUpdate
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php \Drupal\KernelTests\Core\Database\UpdateTest::testSimpleUpdate()
- 10 core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php \Drupal\KernelTests\Core\Database\UpdateTest::testSimpleUpdate()
- 11.x 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 15
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->assertIdentical($num_updated, 1, 'Updated 1 record.');
$saved_name = $this->connection
->query('SELECT name FROM {test} WHERE id = :id', [
':id' => 1,
])
->fetchField();
$this->assertIdentical($saved_name, 'Tiffany', 'Updated name successfully.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.