You are here

protected function FileResourceTestBase::makeCurrentUserFileOwner in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php \Drupal\Tests\file\Functional\Rest\FileResourceTestBase::makeCurrentUserFileOwner()
  2. 9 core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php \Drupal\Tests\file\Functional\Rest\FileResourceTestBase::makeCurrentUserFileOwner()

Makes the current user the file owner.

1 call to FileResourceTestBase::makeCurrentUserFileOwner()
FileResourceTestBase::setUpAuthorization in core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php
Sets up the necessary authorization.

File

core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php, line 65

Class

FileResourceTestBase

Namespace

Drupal\Tests\file\Functional\Rest

Code

protected function makeCurrentUserFileOwner() {
  $account = static::$auth ? User::load(2) : User::load(0);
  $this->entity
    ->setOwnerId($account
    ->id());
  $this->entity
    ->setOwner($account);
  $this->entity
    ->save();
}