function SelectTest::testInvalidSelectCount

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

Tests that an invalid count query throws an exception.

File

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

Class

SelectTest
Tests the Select query builder.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testInvalidSelectCount() : void {
    $this->expectException(DatabaseExceptionWrapper::class);
    // This query will fail because the table does not exist.
    $this->connection
        ->select('some_table_that_does_not_exist', 't')
        ->fields('t')
        ->countQuery()
        ->execute();
}

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