function DeleteTruncateTest::testSimpleDelete
Same name in other branches
- 8.9.x core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php \Drupal\KernelTests\Core\Database\DeleteTruncateTest::testSimpleDelete()
- 10 core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php \Drupal\KernelTests\Core\Database\DeleteTruncateTest::testSimpleDelete()
- 11.x core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php \Drupal\KernelTests\Core\Database\DeleteTruncateTest::testSimpleDelete()
Confirms that we can delete a single record successfully.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ DeleteTruncateTest.php, line 46
Class
- DeleteTruncateTest
- Tests delete and truncate queries.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testSimpleDelete() {
$num_records_before = $this->connection
->query('SELECT COUNT(*) FROM {test}')
->fetchField();
$num_deleted = $this->connection
->delete('test')
->condition('id', 1)
->execute();
$this->assertSame(1, $num_deleted, 'Deleted 1 record.');
$num_records_after = $this->connection
->query('SELECT COUNT(*) FROM {test}')
->fetchField();
$this->assertEquals($num_records_before, $num_records_after + $num_deleted, 'Deletion adds up.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.