You are here

protected function FileManagedUnitTestBase::setUp in Drupal 10

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

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() : void {
  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);
}