You are here

protected function FileManagedUnitTestBase::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php \Drupal\Tests\file\Kernel\FileManagedUnitTestBase::setUp()

Overrides KernelTestBase::setUp

2 calls to FileManagedUnitTestBase::setUp()
SpaceUsedTest::setUp in core/modules/file/tests/src/Kernel/SpaceUsedTest.php
ValidatorTest::setUp in core/modules/file/tests/src/Kernel/ValidatorTest.php
2 methods override FileManagedUnitTestBase::setUp()
SpaceUsedTest::setUp in core/modules/file/tests/src/Kernel/SpaceUsedTest.php
ValidatorTest::setUp in core/modules/file/tests/src/Kernel/ValidatorTest.php

File

core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php, line 24

Class

FileManagedUnitTestBase
Base class for file unit tests that use the file_test module to test uploads and hooks.

Namespace

Drupal\Tests\file\Kernel

Code

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

  // Clear out any hook calls.
  file_test_reset();
  $this
    ->installConfig([
    'system',
  ]);
  $this
    ->installEntitySchema('file');
  $this
    ->installEntitySchema('user');
  $this
    ->installSchema('file', [
    'file_usage',
  ]);

  // Make sure that a user with uid 1 exists, self::createFile() relies on
  // it.
  $user = User::create([
    'uid' => 1,
    'name' => $this
      ->randomMachineName(),
  ]);
  $user
    ->enforceIsNew();
  $user
    ->save();
  \Drupal::currentUser()
    ->setAccount($user);
}