You are here

function DatabaseDeleteTruncateTestCase::testTruncate in SimpleTest 7

Confirm that we can truncate a whole table successfully.

File

tests/database_test.test, line 965

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, t('Truncate really deletes everything.'));
}