3 namespace Drupal\KernelTests\Core\Database;
6 * Tests the Update query builder with LOB fields.
10 class UpdateLobTest extends DatabaseTestBase {
13 * Confirms that we can update a blob column.
15 public function testUpdateOneBlob() {
16 $data = "This is\000a test.";
17 $this->assertTrue(strlen($data) === 15, 'Test data contains a NULL.');
18 $id = db_insert('test_one_blob')
19 ->fields(['blob1' => $data])
23 db_update('test_one_blob')
24 ->condition('id', $id)
25 ->fields(['blob1' => $data])
28 $r = db_query('SELECT * FROM {test_one_blob} WHERE id = :id', [':id' => $id])->fetchAssoc();
29 $this->assertTrue($r['blob1'] === $data, format_string('Can update a blob: id @id, @data.', ['@id' => $id, '@data' => serialize($r)]));
33 * Confirms that we can update two blob columns in the same table.
35 public function testUpdateMultipleBlob() {
36 $id = db_insert('test_two_blobs')
43 db_update('test_two_blobs')
44 ->condition('id', $id)
45 ->fields(['blob1' => 'and so', 'blob2' => 'is this'])
48 $r = db_query('SELECT * FROM {test_two_blobs} WHERE id = :id', [':id' => $id])->fetchAssoc();
49 $this->assertTrue($r['blob1'] === 'and so' && $r['blob2'] === 'is this', 'Can update multiple blobs per row.');