You are here

public function ConnectionTest::testMultipleStatements in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Database/ConnectionTest.php \Drupal\system\Tests\Database\ConnectionTest::testMultipleStatements()

Ensure that you cannot execute multiple statements.

File

core/modules/system/src/Tests/Database/ConnectionTest.php, line 149
Contains \Drupal\system\Tests\Database\ConnectionTest.

Class

ConnectionTest
Tests of the core database system.

Namespace

Drupal\system\Tests\Database

Code

public function testMultipleStatements() {
  $db = Database::getConnection('default', 'default');
  try {
    $db
      ->query('SELECT * FROM {test}; SELECT * FROM {test_people}');
    $this
      ->fail('No exception thrown for multiple statements.');
  } catch (\InvalidArgumentException $e) {
    $this
      ->pass('Exception thrown for multiple statements.');
  }
}