You are here

function DatabaseDeleteTruncateTestCase::testTruncate in Drupal 7

Confirm that we can truncate a whole table successfully.

File

modules/simpletest/tests/database_test.test, line 1136

Class

DatabaseDeleteTruncateTestCase
Delete/Truncate tests.

Code

function testTruncate() {
  $num_records_before = db_query("SELECT COUNT(*) FROM {test}")
    ->fetchField();
  db_truncate('test')
    ->execute();
  $num_records_after = db_query("SELECT COUNT(*) FROM {test}")
    ->fetchField();
  $this
    ->assertEqual(0, $num_records_after, 'Truncate really deletes everything.');
}