You are here

public function MergeTest::testInvalidMerge in Drupal 9

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

Tests that an invalid merge query throws an exception.

File

core/tests/Drupal/KernelTests/Core/Database/MergeTest.php, line 198

Class

MergeTest
Tests the MERGE query builder.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testInvalidMerge() {
  $this
    ->expectException(InvalidMergeQueryException::class);

  // This merge will fail because there is no key field specified.
  $this->connection
    ->merge('test_people')
    ->fields([
    'age' => 31,
    'name' => 'Tiffany',
  ])
    ->execute();
}