| 7 database_test.test | DatabaseSelectTestCase::testSimpleSelectAllFields() |
| 8 database.test | DatabaseSelectTestCase::testSimpleSelectAllFields() |
Test adding all fields from a given table to a select statement.
File
- modules/
simpletest/ tests/ database_test.test, line 1436
Code
function testSimpleSelectAllFields() {
$record = db_select('test')
->fields('test')
->condition('age', 27)
->execute()->fetchObject();
// Check that all fields we asked for are present.
$this->assertNotNull($record->id, t('ID field is present.'));
$this->assertNotNull($record->name, t('Name field is present.'));
$this->assertNotNull($record->age, t('Age field is present.'));
$this->assertNotNull($record->job, t('Job field is present.'));
// Ensure that we got the right record.
// Check that all fields we asked for are present.
$this->assertEqual($record->id, 2, t('ID field has the correct value.'));
$this->assertEqual($record->name, 'George', t('Name field has the correct value.'));
$this->assertEqual($record->age, 27, t('Age field has the correct value.'));
$this->assertEqual($record->job, 'Singer', t('Job field has the correct value.'));
}
Login or register to post comments