You are here

protected function FileResourceTestBase::makeCurrentUserFileOwner in Drupal 8

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

Makes the current user the file owner.

2 calls to FileResourceTestBase::makeCurrentUserFileOwner()
FileResourceTestBase::grantPermissionsToTestedRole in core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php
Grants permissions to the tested role: anonymous or authenticated.
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 80

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