function SelectComplexTest::testSelectWithRowCount

Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php \Drupal\KernelTests\Core\Database\SelectComplexTest::testSelectWithRowCount()
  2. 10 core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php \Drupal\KernelTests\Core\Database\SelectComplexTest::testSelectWithRowCount()
  3. 11.x core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php \Drupal\KernelTests\Core\Database\SelectComplexTest::testSelectWithRowCount()

Tests that rowCount() throws exception on SELECT query.

File

core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php, line 389

Class

SelectComplexTest
Tests the Select query builder with more complex queries.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testSelectWithRowCount() {
    $query = $this->connection
        ->select('test');
    $query->addField('test', 'name');
    $result = $query->execute();
    try {
        $result->rowCount();
        $exception = FALSE;
    } catch (RowCountException $e) {
        $exception = TRUE;
    }
    $this->assertTrue($exception, 'Exception was thrown');
}

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