You are here

public function ShortcutSetsTest::testShortcutSetSwitchNoSetName in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php \Drupal\Tests\shortcut\Functional\ShortcutSetsTest::testShortcutSetSwitchNoSetName()

Tests switching a user's shortcut set without providing a new set name.

File

core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php, line 149

Class

ShortcutSetsTest
Create, view, edit, delete, and change shortcut sets.

Namespace

Drupal\Tests\shortcut\Functional

Code

public function testShortcutSetSwitchNoSetName() {
  $edit = [
    'set' => 'new',
  ];
  $this
    ->drupalGet('user/' . $this->adminUser
    ->id() . '/shortcuts');
  $this
    ->submitForm($edit, 'Change set');
  $this
    ->assertSession()
    ->pageTextContains('The new set label is required.');
  $current_set = shortcut_current_displayed_set($this->adminUser);
  $this
    ->assertEquals($this->set
    ->id(), $current_set
    ->id(), 'Attempting to switch to a new shortcut set without providing a set name does not succeed.');
  $field = $this
    ->assertSession()
    ->fieldExists('label');
  $this
    ->assertTrue($field
    ->hasClass('error'));
}