function UpdateLobTest::testUpdateMultipleBlob

Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php \Drupal\KernelTests\Core\Database\UpdateLobTest::testUpdateMultipleBlob()
  2. 10 core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php \Drupal\KernelTests\Core\Database\UpdateLobTest::testUpdateMultipleBlob()
  3. 11.x core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php \Drupal\KernelTests\Core\Database\UpdateLobTest::testUpdateMultipleBlob()

Confirms that we can update two blob columns in the same table.

File

core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php, line 55

Class

UpdateLobTest
Tests the Update query builder with LOB fields.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testUpdateMultipleBlob() {
    $id = $this->connection
        ->insert('test_two_blobs')
        ->fields([
        'blob1' => 'This is',
        'blob2' => 'a test',
    ])
        ->execute();
    $this->connection
        ->update('test_two_blobs')
        ->condition('id', $id)
        ->fields([
        'blob1' => 'and so',
        'blob2' => 'is this',
    ])
        ->execute();
    $r = $this->connection
        ->query('SELECT * FROM {test_two_blobs} WHERE [id] = :id', [
        ':id' => $id,
    ])
        ->fetchAssoc();
    $this->assertSame('and so', $r['blob1']);
    $this->assertSame('is this', $r['blob2']);
}

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