You are here

public function UpdateLobTest::testUpdateMultipleBlob in Drupal 9

Same name and namespace in other branches
  1. 8 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']);
}