function MergeTest::testInvalidMerge

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/MergeTest.php \Drupal\KernelTests\Core\Database\MergeTest::testInvalidMerge()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Database/MergeTest.php \Drupal\KernelTests\Core\Database\MergeTest::testInvalidMerge()
  3. 11.x 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 200

Class

MergeTest
Tests the MERGE query builder.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testInvalidMerge() : void {
    $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();
}

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