You are here

public function AccessTest::testCreateAccess in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/file/tests/src/Kernel/AccessTest.php \Drupal\Tests\file\Kernel\AccessTest::testCreateAccess()
  2. 10 core/modules/file/tests/src/Kernel/AccessTest.php \Drupal\Tests\file\Kernel\AccessTest::testCreateAccess()

Tests create access checks.

File

core/modules/file/tests/src/Kernel/AccessTest.php, line 117

Class

AccessTest
Tests for the File access control.

Namespace

Drupal\Tests\file\Kernel

Code

public function testCreateAccess() {

  // Anonymous users can create a file by default.
  $this
    ->assertFalse($this->file
    ->access('create'));

  // Authenticated users can create a file by default.
  \Drupal::currentUser()
    ->setAccount($this->user1);
  $this
    ->assertFalse($this->file
    ->access('create'));
}