You are here

public function SelectTest::testSimpleComment in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/SelectTest.php \Drupal\KernelTests\Core\Database\SelectTest::testSimpleComment()

Tests rudimentary SELECT statement with a COMMENT.

File

core/tests/Drupal/KernelTests/Core/Database/SelectTest.php, line 31

Class

SelectTest
Tests the Select query builder.

Namespace

Drupal\KernelTests\Core\Database

Code

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.');
}