function ConnectionTest::testMultipleStatementsForNewPhp

Same name in other branches
  1. 9 core/modules/mysql/tests/src/Kernel/mysql/ConnectionTest.php \Drupal\Tests\mysql\Kernel\mysql\ConnectionTest::testMultipleStatementsForNewPhp()
  2. 10 core/modules/mysql/tests/src/Kernel/mysql/ConnectionTest.php \Drupal\Tests\mysql\Kernel\mysql\ConnectionTest::testMultipleStatementsForNewPhp()
  3. 11.x core/modules/mysql/tests/src/Kernel/mysql/ConnectionTest.php \Drupal\Tests\mysql\Kernel\mysql\ConnectionTest::testMultipleStatementsForNewPhp()

Ensure that you cannot execute multiple statements on MySQL.

File

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

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,
    ]);
}

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