public function DbLogTest::testOverviewLinks in Drupal 9
Same name and namespace in other branches
- 8 core/modules/dblog/tests/src/Functional/DbLogTest.php \Drupal\Tests\dblog\Functional\DbLogTest::testOverviewLinks()
- 10 core/modules/dblog/tests/src/Functional/DbLogTest.php \Drupal\Tests\dblog\Functional\DbLogTest::testOverviewLinks()
Make sure HTML tags are filtered out in the log overview links.
File
- core/
modules/ dblog/ tests/ src/ Functional/ DbLogTest.php, line 845
Class
- DbLogTest
- Generate events and verify dblog entries; verify user access to log reports based on permissions.
Namespace
Drupal\Tests\dblog\FunctionalCode
public function testOverviewLinks() {
$this
->drupalLogin($this->adminUser);
// cSpell:disable-next-line
$this
->generateLogEntries(1, [
'message' => "<script>alert('foo');</script><strong>Lorem</strong> ipsum dolor sit amet, consectetur adipiscing & elit.",
]);
$this
->drupalGet('admin/reports/dblog');
$this
->assertSession()
->statusCodeEquals(200);
// Make sure HTML tags are filtered out.
$this
->assertSession()
->responseContains('title="alert('foo');Lorem');
$this
->assertSession()
->responseNotContains("<script>alert('foo');</script>");
// Make sure HTML tags are filtered out in admin/reports/dblog/event/ too.
$this
->generateLogEntries(1, [
'message' => "<script>alert('foo');</script> <strong>Lorem ipsum</strong>",
]);
$query = Database::getConnection()
->select('watchdog');
$query
->addExpression('MAX([wid])');
$wid = $query
->execute()
->fetchField();
$this
->drupalGet('admin/reports/dblog/event/' . $wid);
$this
->assertSession()
->responseNotContains("<script>alert('foo');</script>");
$this
->assertSession()
->responseContains("alert('foo'); <strong>Lorem ipsum</strong>");
}