public function DbLogTest::testLogEventPageWithMissingInfo in Drupal 9
Same name and namespace in other branches
- 8 core/modules/dblog/tests/src/Functional/DbLogTest.php \Drupal\Tests\dblog\Functional\DbLogTest::testLogEventPageWithMissingInfo()
- 10 core/modules/dblog/tests/src/Functional/DbLogTest.php \Drupal\Tests\dblog\Functional\DbLogTest::testLogEventPageWithMissingInfo()
Tests individual log event page with missing log attributes.
In some cases few log attributes are missing. For example:
- Missing referer: When request is made to a specific url directly and error occurred. In this case there is no referer.
- Incorrect location: When location attribute is incorrect uri which can not be used to generate a valid link.
File
- core/
modules/ dblog/ tests/ src/ Functional/ DbLogTest.php, line 207
Class
- DbLogTest
- Generate events and verify dblog entries; verify user access to log reports based on permissions.
Namespace
Drupal\Tests\dblog\FunctionalCode
public function testLogEventPageWithMissingInfo() {
$this
->drupalLogin($this->adminUser);
$connection = Database::getConnection();
// Test log event page with missing referer.
$this
->generateLogEntries(1, [
'referer' => NULL,
]);
$query = $connection
->select('watchdog');
$query
->addExpression('MAX([wid])');
$wid = $query
->execute()
->fetchField();
$this
->drupalGet('admin/reports/dblog/event/' . $wid);
// Verify table headers are present, even though the referrer is missing.
$this
->assertSession()
->pageTextContains('Referrer');
// Verify severity.
$this
->assertSession()
->pageTextContains('Notice');
// Test log event page with incorrect location.
$request_uri = '/some/incorrect/url';
$this
->generateLogEntries(1, [
'request_uri' => $request_uri,
]);
$query = $connection
->select('watchdog');
$query
->addExpression('MAX([wid])');
$wid = $query
->execute()
->fetchField();
$this
->drupalGet('admin/reports/dblog/event/' . $wid);
// Verify table headers are present.
$this
->assertSession()
->pageTextContains('Location');
// Verify severity.
$this
->assertSession()
->pageTextContains('Notice');
// Verify location is available as plain text.
$this
->assertEquals($request_uri, $this
->cssSelect('table.dblog-event > tbody > tr:nth-child(4) > td')[0]
->getHtml());
$this
->assertSession()
->linkNotExists($request_uri);
}