function DbLogTest::testMessageParsing

Same name in other branches
  1. 9 core/modules/dblog/tests/src/Functional/DbLogTest.php \Drupal\Tests\dblog\Functional\DbLogTest::testMessageParsing()
  2. 11.x core/modules/dblog/tests/src/Functional/DbLogTest.php \Drupal\Tests\dblog\Functional\DbLogTest::testMessageParsing()

Test that twig errors are displayed correctly.

1 call to DbLogTest::testMessageParsing()
DbLogTest::testDbLog in core/modules/dblog/tests/src/Functional/DbLogTest.php
Tests Database Logging module functionality through interfaces.

File

core/modules/dblog/tests/src/Functional/DbLogTest.php, line 286

Class

DbLogTest
Verifies log entries and user access based on permissions.

Namespace

Drupal\Tests\dblog\Functional

Code

protected function testMessageParsing() : void {
    $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.