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 update_post_update_add_view_update_notifications_permission().

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.