You are here

protected function AuditFilesNotOnServerTest::setUp 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::setUp()

Overrides BrowserTestBase::setUp

File

tests/src/Functional/AuditFilesNotOnServerTest.php, line 48

Class

AuditFilesNotOnServerTest
Tests that the "Not on server" report is reachable with no errors.

Namespace

Drupal\Tests\auditfiles\Functional

Code

protected function setUp() : void {
  parent::setUp();

  // Create user with permissions to manage site configuration and access
  // audit files reports.
  $this->user = $this
    ->drupalCreateUser([
    'access audit files reports',
  ]);
  $all_rids = $this->user
    ->getRoles();
  unset($all_rids[array_search(RoleInterface::AUTHENTICATED_ID, $all_rids)]);

  // Save role IDs.
  $this->rid = reset($all_rids);

  // Create File Entities.
  for ($i = 0; $i < 3; $i++) {
    $path = "public://example_{$i}.png";
    $image = File::create([
      'uri' => $path,
      'status' => TRUE,
    ]);
    $image
      ->save();
  }
}