function FileAddPermissionsUpdateTest::testUpdate
Same name in other branches
- 11.x core/modules/file/tests/src/Functional/FileAddPermissionsUpdateTest.php \Drupal\Tests\file\Functional\FileAddPermissionsUpdateTest::testUpdate()
Tests adding 'delete own files' permission.
File
-
core/
modules/ file/ tests/ src/ Functional/ FileAddPermissionsUpdateTest.php, line 32
Class
Namespace
Drupal\Tests\file\FunctionalCode
public function testUpdate() : void {
$roles = Role::loadMultiple();
$this->assertGreaterThan(2, count($roles));
foreach ($roles as $role) {
$permissions = $role->toArray()['permissions'];
$this->assertNotContains('delete own files', $permissions);
}
$this->runUpdates();
$role = Role::load(Role::ANONYMOUS_ID);
$permissions = $role->toArray()['permissions'];
$this->assertNotContains('delete own files', $permissions);
$role = Role::load(Role::AUTHENTICATED_ID);
$permissions = $role->toArray()['permissions'];
$this->assertContains('delete own files', $permissions);
// Admin roles have the permission and do not need assigned.
$role = Role::load('administrator');
$permissions = $role->toArray()['permissions'];
$this->assertNotContains('delete own files', $permissions);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.