You are here

public function AuditFilesManagedNotUsedTest::testReportPage in Audit Files 8.3

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/AuditFilesManagedNotUsedTest.php \Drupal\Tests\auditfiles\Functional\AuditFilesManagedNotUsedTest::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/AuditFilesManagedNotUsedTest.php, line 74

Class

AuditFilesManagedNotUsedTest
Tests that the "Managed not used" report is reachable with no errors.

Namespace

Drupal\Tests\auditfiles\Functional

Code

public function testReportPage() {

  // Form to test.
  $path = Url::fromRoute('auditfiles.audit_files_managednotused');

  // Establish session.
  $session = $this
    ->assertSession();

  // Visit page as anonymous user, should receive a 403.
  $this
    ->drupalGet($path);
  $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
    ->statusCodeEquals(200);
}