function FileResourceTestBase::makeCurrentUserFileOwner

Same name in other branches
  1. 9 core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php \Drupal\Tests\file\Functional\Rest\FileResourceTestBase::makeCurrentUserFileOwner()
  2. 8.9.x core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php \Drupal\Tests\file\Functional\Rest\FileResourceTestBase::makeCurrentUserFileOwner()
  3. 10 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 87

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

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