You are here

public function AuditFilesUsedNotManagedTest::testReportPage in Audit Files 8.3

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

Class

AuditFilesUsedNotManagedTest
Tests that the "Used not managed" report is reachable with no errors.

Namespace

Drupal\Tests\auditfiles\Functional

Code

public function testReportPage() {

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

  // 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('Used not managed');
  $session
    ->statusCodeEquals(200);
}