You are here

public function SelectTest::testSimpleSelect 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::testSimpleSelect()

Tests rudimentary SELECT statements.

File

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

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
    ->assertEqual($num_records, 4, 'Returned the correct number of rows.');
}