diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-05-03 08:56:19 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-05-03 08:56:19 +0000 |
commit | c5926f4961506ad886e6110bc506bf72e4588bc8 (patch) | |
tree | 6efe325fc02f12a6b8e2e12612fe721ac9bbeac5 /modules/simpletest/tests/database_test.test | |
parent | d4193f5178141a3474a08a8f2e77107a5fd5e0a0 (diff) | |
download | brdo-c5926f4961506ad886e6110bc506bf72e4588bc8.tar.gz brdo-c5926f4961506ad886e6110bc506bf72e4588bc8.tar.bz2 |
- Patch #396578 by Damien Tournoud: added db_truncate_table() to the database layer.
Diffstat (limited to 'modules/simpletest/tests/database_test.test')
-rw-r--r-- | modules/simpletest/tests/database_test.test | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test index a59e321aa..da3add21a 100644 --- a/modules/simpletest/tests/database_test.test +++ b/modules/simpletest/tests/database_test.test @@ -847,19 +847,22 @@ class DatabaseUpdateLOBTestCase extends DatabaseTestCase { } /** - * Delete tests. + * Delete/Truncate tests. * * The DELETE tests are not as extensive, as all of the interesting code for * DELETE queries is in the conditional which is identical to the UPDATE and * SELECT conditional handling. * + * The TRUNCATE tests are not extensive either, because the behavior of + * TRUNCATE queries is not consistent across database engines. We only test + * that a TRUNCATE query actually deletes all rows from the target table. */ -class DatabaseDeleteTestCase extends DatabaseTestCase { +class DatabaseDeleteTruncateTestCase extends DatabaseTestCase { public static function getInfo() { return array( - 'name' => t('Delete tests'), - 'description' => t('Test the Delete query builder.'), + 'name' => t('Delete/Truncate tests'), + 'description' => t('Test the Delete and Truncate query builders.'), 'group' => t('Database'), ); } @@ -876,6 +879,19 @@ class DatabaseDeleteTestCase extends DatabaseTestCase { $num_records_after = db_query("SELECT COUNT(*) FROM {test}")->fetchField(); $this->assertEqual($num_records_before, $num_records_after + $num_deleted, t('Deletion adds up.')); } + + + /** + * Confirm that we can truncate a whole table successfully. + */ + 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.')); + } } /** |