function MediaKernelTestBase::setUp

Same name in other branches
  1. 9 core/modules/media/tests/src/Kernel/MediaKernelTestBase.php \Drupal\Tests\media\Kernel\MediaKernelTestBase::setUp()
  2. 8.9.x core/modules/media/tests/src/Kernel/MediaKernelTestBase.php \Drupal\Tests\media\Kernel\MediaKernelTestBase::setUp()
  3. 11.x core/modules/media/tests/src/Kernel/MediaKernelTestBase.php \Drupal\Tests\media\Kernel\MediaKernelTestBase::setUp()

Overrides KernelTestBase::setUp

2 calls to MediaKernelTestBase::setUp()
MediaThumbnailFormatterTest::setUp in core/modules/media/tests/src/Kernel/MediaThumbnailFormatterTest.php
MediaTranslationTest::setUp in core/modules/media/tests/src/Kernel/MediaTranslationTest.php
2 methods override MediaKernelTestBase::setUp()
MediaThumbnailFormatterTest::setUp in core/modules/media/tests/src/Kernel/MediaThumbnailFormatterTest.php
MediaTranslationTest::setUp in core/modules/media/tests/src/Kernel/MediaTranslationTest.php

File

core/modules/media/tests/src/Kernel/MediaKernelTestBase.php, line 59

Class

MediaKernelTestBase
Base class for Media kernel tests.

Namespace

Drupal\Tests\media\Kernel

Code

protected function setUp() : void {
    parent::setUp();
    $this->installEntitySchema('user');
    $this->installEntitySchema('file');
    $this->installSchema('file', 'file_usage');
    $this->installEntitySchema('media');
    $this->installConfig([
        'field',
        'system',
        'image',
        'file',
        'media',
    ]);
    // Create a test media type.
    $this->testMediaType = $this->createMediaType('test');
    // Create a test media type with constraints.
    $this->testConstraintsMediaType = $this->createMediaType('test_constraints');
    $this->user = User::create([
        'name' => 'username',
        'status' => 1,
    ]);
    $this->user
        ->save();
    $this->container
        ->get('current_user')
        ->setAccount($this->user);
}

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