1 database_test.test | DatabaseSelectTestCase::testSimpleComment() |
Test rudimentary SELECT statement with a COMMENT.
File
- core/
modules/ simpletest/ tests/ database_test.test, line 1322 - Database tests.
Class
- DatabaseSelectTestCase
- Test the SELECT builder.
Code
function testSimpleComment() {
$query = db_select('test');
$query->comment('Testing query comments');
$query->addField('test', 'name');
$query->addField('test', 'age', 'age');
$result = $query->execute();
$num_records = 0;
foreach ($result as $record) {
$num_records++;
}
$query = (string) $query;
$expected = "/* Testing query comments */ SELECT test.`name` AS `name`, test.`age` AS `age`\nFROM \n{test} test";
$this->assertEqual($num_records, 4, 'Returned the correct number of rows.');
$this->assertEqual($query, $expected, 'The flattened query contains the comment string.');
}