Updated: Comment #0

Problem/Motivation

In #2073813: Add a UrlGenerator helper to FormBase and ControllerBase a patch was uploaded that broke inline adding of shortcut links. That patch passed tests.

Proposed resolution

Add tests for adding a shortcut link inline.

Remaining tasks

#2073813: Add a UrlGenerator helper to FormBase and ControllerBase

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tstoeckler’s picture

I would need some help here. The following HTML is output:

<a href="/admin/config/user-interface/shortcut/manage/default/add-link-inline?link=node/1&amp;name=**somename**&amp;destination=node/1&amp;token=**sometoken**">
  <span class="icon">Add or remove shortcut</span>
  <span class="text">Add to <em class="placeholder">Default</em> shortcuts</span>
</a>

But I can't seem to be able to target that with $this->clickLink(). :-/

tstoeckler’s picture

Status: Active » Needs work
FileSize
1.32 KB

This is what I started with, maybe someone else can drive this home.
As stated above, the clickLink() in the patch yields notices and does not actually work.

Wim Leers’s picture

Issue summary: View changes
Status: Needs work » Closed (duplicate)

Such test coverage has been added in the mean time:

  /**
   * Tests that the "add to shortcut" and "remove from shortcut" links work.
   */
  public function testShortcutQuickLink() {
    theme_enable(array('seven'));
    \Drupal::config('system.theme')->set('admin', 'seven')->save();
    $this->container->get('config.factory')->get('node.settings')->set('use_admin_theme', '1')->save();
    $this->container->get('router.builder')->rebuild();

    $this->drupalLogin($this->root_user);
    $this->drupalGet('admin/config/system/cron');

    // Test the "Add to shortcuts" link.
    $this->clickLink('Add to Default shortcuts');
    $this->assertText('Added a shortcut for Cron.');
    $this->assertLink('Cron', 0, 'Shortcut link found on page');

    $this->drupalGet('admin/structure');
    $this->assertLink('Cron', 0, 'Shortcut link found on different page');

    // Test the "Remove from shortcuts" link.
    $this->clickLink('Cron');
    $this->clickLink('Remove from Default shortcuts');
    $this->drupalPostForm(NULL, array(), 'Delete');
    $this->assertText('The shortcut Cron has been deleted.');
    $this->assertNoLink('Cron', 'Shortcut link removed from page');

    $this->drupalGet('admin/structure');
    $this->assertNoLink('Cron', 'Shortcut link removed from different page');
  }