class UpdateAddViewUpdateNotificationsPermissionTest

Tests update_post_update_add_view_update_notifications_permission().

@group Update @group legacy

Hierarchy

Expanded class hierarchy of UpdateAddViewUpdateNotificationsPermissionTest

File

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

Namespace

Drupal\Tests\update\Functional\Update
View source
class UpdateAddViewUpdateNotificationsPermissionTest extends UpdatePathTestBase {
  use UserCreationTrait;
  
  /**
   * {@inheritdoc}
   */
  protected function setDatabaseDumpFiles() : void {
    $this->databaseDumpFiles = [
      __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-9.3.0.filled.standard.php.gz',
    ];
  }
  
  /**
   * Tests that the 'view update notifications' permission is correctly granted.
   */
  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.