You are here

function DatabaseUpdateLOBTestCase::testUpdateOneBlob in SimpleTest 7

Confirm that we can update a blob column.

File

tests/database_test.test, line 887

Class

DatabaseUpdateLOBTestCase
Test update queries involving LOB values.

Code

function testUpdateOneBlob() {
  $data = "This is\0a test.";
  $this
    ->assertTrue(strlen($data) === 15, t('Test data contains a NULL.'));
  $id = db_insert('test_one_blob')
    ->fields(array(
    'blob1' => $data,
  ))
    ->execute();
  $data .= $data;
  db_update('test_one_blob')
    ->condition('id', $id)
    ->fields(array(
    'blob1' => $data,
  ))
    ->execute();
  $r = db_query('SELECT * FROM {test_one_blob} WHERE id = :id', array(
    ':id' => $id,
  ))
    ->fetchAssoc();
  $this
    ->assertTrue($r['blob1'] === $data, t('Can update a blob: id @id, @data.', array(
    '@id' => $id,
    '@data' => serialize($r),
  )));
}