function UpdateLobTest::testUpdateMultipleBlob

Same name in other branches
  1. 9 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 37

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->assertTrue($r['blob1'] === 'and so' && $r['blob2'] === 'is this', 'Can update multiple blobs per row.');
}

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