function InsertLobTest::testInsertOneBlob
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Database/InsertLobTest.php \Drupal\KernelTests\Core\Database\InsertLobTest::testInsertOneBlob()
- 8.9.x core/tests/Drupal/KernelTests/Core/Database/InsertLobTest.php \Drupal\KernelTests\Core\Database\InsertLobTest::testInsertOneBlob()
- 11.x core/tests/Drupal/KernelTests/Core/Database/InsertLobTest.php \Drupal\KernelTests\Core\Database\InsertLobTest::testInsertOneBlob()
Tests that we can insert a single blob field successfully.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ InsertLobTest.php, line 17
Class
- InsertLobTest
- Tests the Insert query builder with LOB fields.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testInsertOneBlob() : void {
$data = "This is\x00a test.";
$this->assertSame(15, strlen($data), 'Test data contains a NULL.');
$id = $this->connection
->insert('test_one_blob')
->fields([
'blob1' => $data,
])
->execute();
$r = $this->connection
->query('SELECT * FROM {test_one_blob} WHERE [id] = :id', [
':id' => $id,
])
->fetchAssoc();
$this->assertSame($data, $r['blob1'], "Can insert a blob: id {$id}, " . serialize($r));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.