function InsertLobTest::testInsertOneBlob in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Database/InsertLobTest.php \Drupal\system\Tests\Database\InsertLobTest::testInsertOneBlob()
Tests that we can insert a single blob field successfully.
File
- core/
modules/ system/ src/ Tests/ Database/ InsertLobTest.php, line 20 - Contains \Drupal\system\Tests\Database\InsertLobTest.
Class
- InsertLobTest
- Tests the Insert query builder with LOB fields.
Namespace
Drupal\system\Tests\DatabaseCode
function testInsertOneBlob() {
$data = "This is\0a test.";
$this
->assertTrue(strlen($data) === 15, 'Test data contains a NULL.');
$id = db_insert('test_one_blob')
->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, format_string('Can insert a blob: id @id, @data.', array(
'@id' => $id,
'@data' => serialize($r),
)));
}