You are here

public function ConnectionTest::testMultipleStatementsForNewPhp in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php \Drupal\KernelTests\Core\Database\ConnectionTest::testMultipleStatementsForNewPhp()

Ensure that you cannot execute multiple statements on MySQL.

File

core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php, line 208

Class

ConnectionTest
Tests of the core database system.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testMultipleStatementsForNewPhp() {

  // This just tests mysql, as other PDO integrations don't allow disabling
  // multiple statements.
  if (Database::getConnection()
    ->databaseType() !== 'mysql') {
    $this
      ->markTestSkipped("This test only runs for MySQL");
  }

  // Disable the protection at the PHP level.
  $this
    ->expectException(DatabaseExceptionWrapper::class);
  Database::getConnection('default', 'default')
    ->query('SELECT * FROM {test}; SELECT * FROM {test_people}', [], [
    'allow_delimiter_in_query' => TRUE,
  ]);
}