You are here

public function AuditFilesNotOnServerTest::testReportPage in Audit Files 8.3

Same name and namespace in other branches
  1. 8.2 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\Functional

Code

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);
}