function UpsertTest::testUpsertNonExistingTable

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/UpsertTest.php \Drupal\KernelTests\Core\Database\UpsertTest::testUpsertNonExistingTable()
  2. 11.x core/tests/Drupal/KernelTests/Core/Database/UpsertTest.php \Drupal\KernelTests\Core\Database\UpsertTest::testUpsertNonExistingTable()

Upsert on a not existing table throws a DatabaseExceptionWrapper.

File

core/tests/Drupal/KernelTests/Core/Database/UpsertTest.php, line 115

Class

UpsertTest
Tests the Upsert query builder.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testUpsertNonExistingTable() : void {
    $this->expectException(DatabaseExceptionWrapper::class);
    $upsert = $this->connection
        ->upsert('a-table-that-does-not-exist')
        ->key('id')
        ->fields([
        'id',
        'update',
    ]);
    $upsert->values([
        'id' => 1,
        'update' => 'Update value 1 updated',
    ]);
    $upsert->execute();
}

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