function FileManagedUnitTestBase::setUp

Same name in other branches
  1. 9 core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php \Drupal\Tests\file\Kernel\FileManagedUnitTestBase::setUp()
  2. 10 core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php \Drupal\Tests\file\Kernel\FileManagedUnitTestBase::setUp()
  3. 11.x 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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.