function DbLogTest::testMessageParsing
Same name in other branches
- 10 core/modules/dblog/tests/src/Functional/DbLogTest.php \Drupal\Tests\dblog\Functional\DbLogTest::testMessageParsing()
- 11.x core/modules/dblog/tests/src/Functional/DbLogTest.php \Drupal\Tests\dblog\Functional\DbLogTest::testMessageParsing()
Test that twig errors are displayed correctly.
File
-
core/
modules/ dblog/ tests/ src/ Functional/ DbLogTest.php, line 250
Class
- DbLogTest
- Verifies log entries and user access 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');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.