function SelectTest::testSimpleComment
Tests rudimentary SELECT statement with a COMMENT.
File
- 
              core/tests/ Drupal/ KernelTests/ Core/ Database/ SelectTest.php, line 32 
Class
- SelectTest
- Tests the Select query builder.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testSimpleComment() {
  $query = $this->connection
    ->select('test')
    ->comment('Testing query comments');
  $query->addField('test', 'name');
  $query->addField('test', 'age', 'age');
  $result = $query->execute();
  $records = $result->fetchAll();
  $query = (string) $query;
  $expected = "/* Testing query comments */";
  $this->assertCount(4, $records, 'Returned the correct number of rows.');
  $this->assertStringContainsString($expected, $query, 'The flattened query contains the comment string.');
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
