function SelectTest::testSimpleSelect

Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/Database/SelectTest.php \Drupal\KernelTests\Core\Database\SelectTest::testSimpleSelect()
  2. 10 core/tests/Drupal/KernelTests/Core/Database/SelectTest.php \Drupal\KernelTests\Core\Database\SelectTest::testSimpleSelect()
  3. 11.x 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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.