function UpdatePathTest::insertLogEntry
Inserts a row into the watchdog table.
Parameters
\Drupal\Core\Database\Connection $connection: The database connection.
int|null $wid: An explicit watchdog ID, or NULL to let the sequence assign one.
File
-
core/
modules/ dblog/ tests/ src/ Functional/ UpdatePathTest.php, line 75
Class
- UpdatePathTest
- Tests update functions for the Database Logging module.
Namespace
Drupal\Tests\dblog\FunctionalCode
private function insertLogEntry(Connection $connection, ?int $wid = NULL) : void {
global $base_root;
$fields = [
'message' => 'Dblog test log message',
'type' => 'test',
'variables' => '',
'severity' => RfcLogLevel::NOTICE,
'uid' => 1,
'location' => $base_root . \Drupal::request()->getRequestUri(),
'hostname' => $base_root,
'timestamp' => \Drupal::time()->getRequestTime(),
];
if ($wid !== NULL) {
$fields['wid'] = $wid;
}
$connection->insert('watchdog')
->fields($fields)
->execute();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.