Verified Commit b62d87be authored by Dave Long's avatar Dave Long
Browse files

fix: #3389633 SwitchShortcutSet form does not set access on machine name element

By: smustgrave
By: brad.bulger
By: dcam
(cherry picked from commit 508e5ebf)
parent ab20bac8
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -103,6 +103,7 @@ public function buildForm(array $form, FormStateInterface $form_state, ?UserInte
      ];
      $form['id'] = [
        '#type' => 'machine_name',
        '#access' => $add_access,
        '#machine_name' => [
          'exists' => [$this, 'exists'],
          'replace_pattern' => '[^a-z0-9-]+',
+10 −0
Original line number Diff line number Diff line
@@ -174,6 +174,16 @@ public function testShortcutSetSwitchCreate(): void {
    $current_set = $shortcut_set_storage->getDisplayedToUser($this->adminUser);
    $this->assertNotEquals($this->set->id(), $current_set->id(), 'A shortcut set can be switched to at the same time as it is created.');
    $this->assertEquals($edit['label'], $current_set->label(), 'The new set is correctly assigned to the user.');

    // Verify that users without the "administer shortcuts" permission have
    // access to the set selection radios, but not the new shortcut form
    // elements.
    $this->drupalLogin($this->shortcutUser);
    $this->drupalGet('user/' . $this->shortcutUser->id() . '/shortcuts');
    $this->assertSession()->elementExists('xpath', '//fieldset[@data-drupal-selector="edit-set"]');
    $this->assertSession()->elementNotExists('xpath', '//input[@id="edit-set-new"]');
    $this->assertSession()->elementNotExists('xpath', '//input[@id="edit-label"]');
    $this->assertSession()->elementNotExists('xpath', '//input[@id="edit-id"]');
  }

  /**