public function AccessTest::testOnlyOwnerCanDeleteUpdateFile in Drupal 8
Same name and namespace in other branches
- 9 core/modules/file/tests/src/Kernel/AccessTest.php \Drupal\Tests\file\Kernel\AccessTest::testOnlyOwnerCanDeleteUpdateFile()
- 10 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'));
}