function InsertDefaultsTest::testDefaultEmptyInsert in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Database/InsertDefaultsTest.php \Drupal\system\Tests\Database\InsertDefaultsTest::testDefaultEmptyInsert()
Tests that no action will be preformed if no fields are specified.
File
- core/
modules/ system/ src/ Tests/ Database/ InsertDefaultsTest.php, line 35 - Contains \Drupal\system\Tests\Database\InsertDefaultsTest.
Class
- InsertDefaultsTest
- Tests the Insert query builder with default values.
Namespace
Drupal\system\Tests\DatabaseCode
function testDefaultEmptyInsert() {
$num_records_before = (int) db_query('SELECT COUNT(*) FROM {test}')
->fetchField();
try {
db_insert('test')
->execute();
// This is only executed if no exception has been thrown.
$this
->fail('Expected exception NoFieldsException has not been thrown.');
} catch (NoFieldsException $e) {
$this
->pass('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, 'Do nothing as no fields are specified.');
}