function DbLogTest::testInvalidPlaceholders

Same name in other branches
  1. 11.x core/modules/dblog/tests/src/Kernel/DbLogTest.php \Drupal\Tests\dblog\Kernel\DbLogTest::testInvalidPlaceholders()

Tests that only valid placeholders are stored in the variables column.

File

core/modules/dblog/tests/src/Kernel/DbLogTest.php, line 68

Class

DbLogTest
Generate events and verify dblog entries.

Namespace

Drupal\Tests\dblog\Kernel

Code

public function testInvalidPlaceholders() : void {
    \Drupal::logger('my_module')->warning('Hello @string @array @object', [
        '@string' => '',
        '@array' => [],
        '@object' => new \stdClass(),
    ]);
    $variables = \Drupal::database()->select('watchdog', 'w')
        ->fields('w', [
        'variables',
    ])
        ->orderBy('wid', 'DESC')
        ->range(0, 1)
        ->execute()
        ->fetchField();
    $this->assertSame(serialize([
        '@string' => '',
    ]), $variables);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.