function FileManagedUnitTestBase::setUp

Same name in other branches
  1. 8.9.x 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

5 calls to FileManagedUnitTestBase::setUp()
CopyTest::setUp in core/modules/file/tests/src/Kernel/CopyTest.php
FileRepositoryTest::setUp in core/modules/file/tests/src/Kernel/FileRepositoryTest.php
MoveTest::setUp in core/modules/file/tests/src/Kernel/MoveTest.php
SpaceUsedTest::setUp in core/modules/file/tests/src/Kernel/SpaceUsedTest.php
ValidatorTest::setUp in core/modules/file/tests/src/Kernel/ValidatorTest.php
5 methods override FileManagedUnitTestBase::setUp()
CopyTest::setUp in core/modules/file/tests/src/Kernel/CopyTest.php
FileRepositoryTest::setUp in core/modules/file/tests/src/Kernel/FileRepositoryTest.php
MoveTest::setUp in core/modules/file/tests/src/Kernel/MoveTest.php
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 26

Class

FileManagedUnitTestBase
Provides a base class for testing file uploads and hook invocations.

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.