function UpdateAddViewUpdateNotificationsPermissionTest::testViewUpdateNotificationsPermission

Tests that the 'view update notifications' permission is correctly granted.

File

core/modules/update/tests/src/Functional/Update/UpdateAddViewUpdateNotificationsPermissionTest.php, line 31

Class

UpdateAddViewUpdateNotificationsPermissionTest
Tests <a href="/api/drupal/core%21modules%21update%21update.post_update.php/function/update_post_update_add_view_update_notifications_permission/9" title="Add &#039;view update notifications&#039; to roles with &#039;administer site configuration&#039;." class="local">update_post_update_add_view_update_notifications_permission</a>().

Namespace

Drupal\Tests\update\Functional\Update

Code

public function testViewUpdateNotificationsPermission() : void {
    // Add a new 'Junior Admin' role with the legacy permission we care about.
    $junior_admin = $this->createRole([
        'administer site configuration',
    ], 'junior_admin', 'Junior Admin');
    $role = Role::load('junior_admin');
    $this->assertTrue($role->hasPermission('administer site configuration'), 'Junior Admin role has legacy permission.');
    $this->assertFalse($role->hasPermission('view update notifications'), 'Junior Admin role does not have the new permission.');
    $this->runUpdates();
    $role = Role::load('junior_admin');
    $this->assertTrue($role->hasPermission('administer site configuration'), 'Junior Admin role still has the legacy permission.');
    $this->assertTrue($role->hasPermission('view update notifications'), 'Junior Admin role now has the new permission.');
}

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