Skip to content
Snippets Groups Projects
Commit fd48bdb1 authored by Project Update Bot's avatar Project Update Bot Committed by Jordan Thompson
Browse files

Issue #3297982 by Project Update Bot, Rajab Natshah, taniachque: Automated...

Issue #3297982 by Project Update Bot, Rajab Natshah, taniachque: Automated Drupal 10 compatibility fixes
parent 8243374f
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,6 @@
},
"license": "GPL-2.0-or-later",
"require": {
"drupal/core": "^8 || ^9"
"drupal/core": "^9.1 || ^10"
}
}
name: RoleAssign
description: 'Allows site administrators to further delegate the task of managing user''s roles.'
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^9.1 || ^10
type: module
configure: roleassign.settings
......@@ -44,12 +44,12 @@ class RoleAssignPermissionTest extends BrowserTestBase {
*
* @var array
*/
public static $modules = ['roleassign'];
protected static $modules = ['roleassign'];
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
// Add Editor role.
......@@ -83,7 +83,7 @@ class RoleAssignPermissionTest extends BrowserTestBase {
*/
public function testRoleAssignSettings() {
$assignable_roles = array_filter(\Drupal::config('roleassign.settings')->get('roleassign_roles'));
$this->assertIdentical(['editor' => 'editor', 'webmaster' => 'webmaster'], $assignable_roles);
$this->assertSame(['editor' => 'editor', 'webmaster' => 'webmaster'], $assignable_roles);
}
/**
......@@ -97,26 +97,28 @@ class RoleAssignPermissionTest extends BrowserTestBase {
$this->drupalGet('user/' . $this->testAccount->id() . '/edit');
// Check that only assignable roles are displayed.
$this->assertText(t('Assignable roles'));
$this->assertNoFieldChecked('edit-roles-editor');
$this->assertNoFieldChecked('edit-roles-webmaster');
$this->assertNoField('edit-roles-siteadmin');
$this->assertSession()->pageTextContains(t('Assignable roles'));
$this->assertSession()->checkboxNotChecked('edit-roles-editor');
$this->assertSession()->checkboxNotChecked('edit-roles-webmaster');
$this->assertSession()->fieldNotExists('edit-roles-siteadmin');
$this->drupalGet('user/' . $this->testAccount->id() . '/edit');
// Assign the role "editor" to the account.
$this->drupalPostForm('user/' . $this->testAccount->id() . '/edit', ["roles[editor]" => "editor"], t('Save'));
$this->assertText(t('The changes have been saved.'));
$this->assertFieldChecked('edit-roles-editor', 'Role editor is assigned.');
$this->assertNoFieldChecked('edit-roles-webmaster');
$this->assertNoField('edit-roles-siteadmin');
$this->submitForm(["roles[editor]" => "editor"], t('Save'));
$this->assertSession()->pageTextContains(t('The changes have been saved.'));
$this->assertSession()->checkboxChecked('edit-roles-editor', 'Role editor is assigned.');
$this->assertSession()->checkboxNotChecked('edit-roles-webmaster');
$this->assertSession()->fieldNotExists('edit-roles-siteadmin');
$this->userLoadAndCheckRoleAssigned($this->testAccount, 'editor');
$this->userLoadAndCheckRoleAssigned($this->testAccount, RoleInterface::AUTHENTICATED_ID);
$this->drupalGet('user/' . $this->testAccount->id() . '/edit');
// Remove the role "editor" from the account.
$this->drupalPostForm('user/' . $this->testAccount->id() . '/edit', ["roles[editor]" => FALSE], t('Save'));
$this->assertText(t('The changes have been saved.'));
$this->assertNoFieldChecked('edit-roles-editor', 'Role editor is removed.');
$this->assertNoFieldChecked('edit-roles-webmaster');
$this->assertNoField('edit-roles-siteadmin');
$this->submitForm(["roles[editor]" => FALSE], t('Save'));
$this->assertSession()->pageTextContains(t('The changes have been saved.'));
$this->assertSession()->checkboxNotChecked('edit-roles-editor', 'Role editor is removed.');
$this->assertSession()->checkboxNotChecked('edit-roles-webmaster');
$this->assertSession()->fieldNotExists('edit-roles-siteadmin');
$this->userLoadAndCheckRoleAssigned($this->testAccount, 'editor', FALSE);
$this->userLoadAndCheckRoleAssigned($this->testAccount, RoleInterface::AUTHENTICATED_ID);
......@@ -144,27 +146,29 @@ class RoleAssignPermissionTest extends BrowserTestBase {
$this->drupalGet('user/' . $this->testAccount->id() . '/edit');
// Check that Drupal default roles checkboxes are shown.
$this->assertText(t('Roles'));
$this->assertNoFieldChecked('edit-roles-editor');
$this->assertNoFieldChecked('edit-roles-webmaster');
$this->assertNoFieldChecked('edit-roles-siteadmin');
$this->assertSession()->pageTextContains(t('Roles'));
$this->assertSession()->checkboxNotChecked('edit-roles-editor');
$this->assertSession()->checkboxNotChecked('edit-roles-webmaster');
$this->assertSession()->checkboxNotChecked('edit-roles-siteadmin');
$this->drupalGet('user/' . $this->testAccount->id() . '/edit');
// Assign the role "SiteAdmin" to the account.
$this->drupalPostForm('user/' . $this->testAccount->id() . '/edit', ["roles[siteadmin]" => "siteadmin"], t('Save'));
$this->assertText(t('The changes have been saved.'));
$this->assertFieldChecked('edit-roles-siteadmin', 'Role siteadmin is assigned.');
$this->submitForm(["roles[siteadmin]" => "siteadmin"], t('Save'));
$this->assertSession()->pageTextContains(t('The changes have been saved.'));
$this->assertSession()->checkboxChecked('edit-roles-siteadmin', 'Role siteadmin is assigned.');
$this->userLoadAndCheckRoleAssigned($this->testAccount, 'siteadmin');
$this->userLoadAndCheckRoleAssigned($this->testAccount, RoleInterface::AUTHENTICATED_ID);
// Now log in as restricted user again.
$this->drupalLogin($this->restrictedUser);
$this->drupalGet('user/' . $this->testAccount->id() . '/edit');
// Assign the role "editor" to the account, and test that the assigned
// "siteadmin" role doesn't get lost.
$this->drupalPostForm('user/' . $this->testAccount->id() . '/edit', ["roles[editor]" => "editor"], t('Save'));
$this->assertText(t('The changes have been saved.'));
$this->assertFieldChecked('edit-roles-editor', 'Role editor is assigned.');
$this->assertNoField('edit-roles-siteadmin');
$this->submitForm(["roles[editor]" => "editor"], t('Save'));
$this->assertSession()->pageTextContains(t('The changes have been saved.'));
$this->assertSession()->checkboxChecked('edit-roles-editor', 'Role editor is assigned.');
$this->assertSession()->fieldNotExists('edit-roles-siteadmin');
$this->userLoadAndCheckRoleAssigned($this->testAccount, 'editor');
$this->userLoadAndCheckRoleAssigned($this->testAccount, RoleInterface::AUTHENTICATED_ID);
$this->userLoadAndCheckRoleAssigned($this->testAccount, 'siteadmin');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment