Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php \Drupal\KernelTests\Core\Database\UpdateLobTest::testUpdateOneBlob()
  2. 9 core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php \Drupal\KernelTests\Core\Database\UpdateLobTest::testUpdateOneBlob()

Confirms that we can update a blob column.

File

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

Class

UpdateLobTest
Tests the Update query builder with LOB fields.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testUpdateOneBlob() {
  $data = "This is\0a test.";
  $this
    ->assertSame(15, strlen($data), 'Test data contains a NULL.');
  $id = $this->connection
    ->insert('test_one_blob')
    ->fields([
    'blob1' => $data,
  ])
    ->execute();
  $data .= $data;
  $this->connection
    ->update('test_one_blob')
    ->condition('id', $id)
    ->fields([
    'blob1' => $data,
  ])
    ->execute();
  $r = $this->connection
    ->query('SELECT * FROM {test_one_blob} WHERE [id] = :id', [
    ':id' => $id,
  ])
    ->fetchAssoc();
  $this
    ->assertSame($data, $r['blob1'], new FormattableMarkup('Can update a blob: id @id, @data.', [
    '@id' => $id,
    '@data' => serialize($r),
  ]));
}