function MergeTest::testInvalidMerge

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

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