function ShortcutSetsTest::testShortcutSetSwitchNoSetName

Same name in other branches
  1. 9 core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php \Drupal\Tests\shortcut\Functional\ShortcutSetsTest::testShortcutSetSwitchNoSetName()
  2. 8.9.x core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php \Drupal\Tests\shortcut\Functional\ShortcutSetsTest::testShortcutSetSwitchNoSetName()
  3. 10 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 152

Class

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

Namespace

Drupal\Tests\shortcut\Functional

Code

public function testShortcutSetSwitchNoSetName() : void {
    $edit = [
        'set' => 'new',
    ];
    $this->drupalGet('user/' . $this->adminUser
        ->id() . '/shortcuts');
    $this->submitForm($edit, 'Change set');
    $this->assertSession()
        ->pageTextContains('The new set label is required.');
    $shortcut_set_storage = \Drupal::entityTypeManager()->getStorage('shortcut_set');
    $current_set = $shortcut_set_storage->getDisplayedToUser($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'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.