public function DbLogTest::testMessageParsing in Drupal 10
Test that twig errors are displayed correctly.
File
- core/
modules/ dblog/ tests/ src/ Functional/ DbLogTest.php, line 252
Class
- DbLogTest
- Generate events and verify dblog entries; verify user access to log reports based on permissions.
Namespace
Drupal\Tests\dblog\FunctionalCode
public function testMessageParsing() {
$this
->drupalLogin($this->adminUser);
// Log a common twig error with {{ }} and { } variables.
\Drupal::service('logger.factory')
->get("php")
->error('Incorrect parameter {{foo}} in path {path}: {value}', [
'foo' => 'bar',
'path' => '/baz',
'value' => 'horse',
]);
// View the log page to verify it's correct.
$wid = \Drupal::database()
->query('SELECT MAX(wid) FROM {watchdog}')
->fetchField();
$this
->drupalGet('admin/reports/dblog/event/' . $wid);
$this
->assertSession()
->responseContains('Incorrect parameter {bar} in path /baz: horse');
}