You are here

public function SelectComplexTest::testSelectWithRowCount in Drupal 8

Same name and namespace in other branches
  1. 9 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 379

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