function AccessTest::testCreateAccess

Same name in other branches
  1. 9 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()
  3. 11.x 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'));
}

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