You are here

public function SelectTest::testSimpleSelect in Drupal 9

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

Tests rudimentary SELECT statements.

File

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

Class

SelectTest
Tests the Select query builder.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testSimpleSelect() {
  $query = $this->connection
    ->select('test');
  $query
    ->addField('test', 'name');
  $query
    ->addField('test', 'age', 'age');
  $num_records = $query
    ->countQuery()
    ->execute()
    ->fetchField();
  $this
    ->assertEquals(4, $num_records, 'Returned the correct number of rows.');
}