| 7 database_test.test | DatabaseInsertDefaultsTestCase::testDefaultEmptyInsert() |
| 8 database.test | DatabaseInsertDefaultsTestCase::testDefaultEmptyInsert() |
Test that no action will be preformed if no fields are specified.
File
- modules/
simpletest/ tests/ database_test.test, line 663
Code
function testDefaultEmptyInsert() {
$num_records_before = (int) db_query('SELECT COUNT(*) FROM {test}')->fetchField();
try {
$result = db_insert('test')->execute();
// This is only executed if no exception has been thrown.
$this->fail(t('Expected exception NoFieldsException has not been thrown.'));
}
catch (NoFieldsException $e) {
$this->pass(t('Expected exception NoFieldsException has been thrown.'));
}
$num_records_after = (int) db_query('SELECT COUNT(*) FROM {test}')->fetchField();
$this->assertIdentical($num_records_before, $num_records_after, t('Do nothing as no fields are specified.'));
}
Login or register to post comments