public function AuditFilesNotOnServerTest::testReportPage in Audit Files 8.2
Same name and namespace in other branches
- 8.3 tests/src/Functional/AuditFilesNotOnServerTest.php \Drupal\Tests\auditfiles\Functional\AuditFilesNotOnServerTest::testReportPage()
Tests report page returns correct HTTP response code.
403 for anonymous users (also for users without permission). 200 for authenticated user with 'access audit files reports' perm.
File
- tests/
src/ Functional/ AuditFilesNotOnServerTest.php, line 74
Class
- AuditFilesNotOnServerTest
- Tests that the "Not on server" report is reachable with no errors.
Namespace
Drupal\Tests\auditfiles\FunctionalCode
public function testReportPage() {
// Form to test.
$path = URL::fromRoute('auditfiles.audit_files_notonserver');
// Establish session.
$session = $this
->assertSession();
// Visit page as anonymous user, should receive a 403.
$this
->drupalGet($path);
$session
->pageTextContains('Access denied');
$session
->statusCodeEquals(403);
// Log in as admin user.
$this
->drupalLogin($this->user);
// Test that report page returns a 200 response code.
$this
->drupalGet($path);
$session
->pageTextContains('Not on server');
$session
->statusCodeEquals(200);
}