You are here

private function DbLogTest::verifyLinkEscaping in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/dblog/tests/src/Functional/DbLogTest.php \Drupal\Tests\dblog\Functional\DbLogTest::verifyLinkEscaping()
  2. 9 core/modules/dblog/tests/src/Functional/DbLogTest.php \Drupal\Tests\dblog\Functional\DbLogTest::verifyLinkEscaping()

Tests the escaping of links in the operation row of a database log detail page.

File

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

Class

DbLogTest
Generate events and verify dblog entries; verify user access to log reports based on permissions.

Namespace

Drupal\Tests\dblog\Functional

Code

private function verifyLinkEscaping() {
  $link = Link::fromTextAndUrl('View', Url::fromRoute('entity.node.canonical', [
    'node' => 1,
  ]))
    ->toString();
  $message = 'Log entry added to do the verifyLinkEscaping test.';
  $this
    ->generateLogEntries(1, [
    'message' => $message,
    'link' => $link,
  ]);
  $result = Database::getConnection()
    ->select('watchdog', 'w')
    ->fields('w', [
    'wid',
  ])
    ->orderBy('wid', 'DESC')
    ->range(0, 1)
    ->execute();
  $this
    ->drupalGet('admin/reports/dblog/event/' . $result
    ->fetchField());

  // Check if the link exists (unescaped).
  $this
    ->assertSession()
    ->responseContains($link);
}