1 database_test.test DatabaseDeleteTruncateTestCase::testTruncate()

Confirm that we can truncate a whole table successfully.

File

core/modules/simpletest/tests/database_test.test, line 1083
Database tests.

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.');
}