function UpdateTest::testToString
Tests the Update::__toString() method.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ UpdateTest.php, line 178
Class
- UpdateTest
- Tests the update query builder.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testToString() : void {
// Prepare query for testing.
$query = $this->connection
->update('test')
->fields([
'a' => 27,
'b' => 42,
])
->condition('c', [
1,
2,
], 'IN');
// Confirm placeholders are present.
$query_string = (string) $query;
$this->assertStringContainsString(':db_update_placeholder_0', $query_string);
$this->assertStringContainsString(':db_update_placeholder_1', $query_string);
$this->assertStringContainsString(':db_condition_placeholder_0', $query_string);
$this->assertStringContainsString(':db_condition_placeholder_1', $query_string);
// Test arguments.
$expected = [
':db_update_placeholder_0' => 27,
':db_update_placeholder_1' => 42,
':db_condition_placeholder_0' => 1,
':db_condition_placeholder_1' => 2,
];
$this->assertEquals($expected, $query->arguments());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.