function AccessTest::testOnlyOwnerCanDeleteUpdateFile
Same name in other branches
- 8.9.x core/modules/file/tests/src/Kernel/AccessTest.php \Drupal\Tests\file\Kernel\AccessTest::testOnlyOwnerCanDeleteUpdateFile()
Tests that only the file owner can delete or update a file.
File
-
core/
modules/ file/ tests/ src/ Kernel/ AccessTest.php, line 77
Class
- AccessTest
- Tests for the File access control.
Namespace
Drupal\Tests\file\KernelCode
public function testOnlyOwnerCanDeleteUpdateFile() {
\Drupal::currentUser()->setAccount($this->user2);
$this->assertFalse($this->file
->access('delete'));
$this->assertFalse($this->file
->access('update'));
\Drupal::currentUser()->setAccount($this->user1);
$this->assertTrue($this->file
->access('delete'));
$this->assertTrue($this->file
->access('update'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.