public function ShortcutLinksTest::testShortcutQuickLink in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/shortcut/src/Tests/ShortcutLinksTest.php \Drupal\shortcut\Tests\ShortcutLinksTest::testShortcutQuickLink()
Tests that the "add to shortcut" and "remove from shortcut" links work.
File
- core/
modules/ shortcut/ src/ Tests/ ShortcutLinksTest.php, line 137 - Contains \Drupal\shortcut\Tests\ShortcutLinksTest.
Class
- ShortcutLinksTest
- Create, view, edit, delete, and change shortcut links.
Namespace
Drupal\shortcut\TestsCode
public function testShortcutQuickLink() {
\Drupal::service('theme_handler')
->install(array(
'seven',
));
$this
->config('system.theme')
->set('admin', 'seven')
->save();
$this
->config('node.settings')
->set('use_admin_theme', '1')
->save();
$this->container
->get('router.builder')
->rebuild();
$this
->drupalLogin($this->rootUser);
$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
->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');
$this
->drupalGet('admin/people');
// Test the "Add to shortcuts" link for a page generated by views.
$this
->clickLink('Add to Default shortcuts');
$this
->assertText('Added a shortcut for People.');
// Due to the structure of the markup in the link ::assertLink() doesn't
// works here.
$link = $this
->xpath('//a[normalize-space()=:label]', array(
':label' => 'Remove from Default shortcuts',
));
$this
->assertTrue(!empty($link), 'Link Remove from Default shortcuts found.');
// Test the "Remove from shortcuts" link for a page generated by views.
$this
->clickLink('Remove from Default shortcuts');
$this
->assertText('The shortcut People has been deleted.');
// Due to the structure of the markup in the link ::assertLink() doesn't
// works here.
$link = $this
->xpath('//a[normalize-space()=:label]', array(
':label' => 'Add to Default shortcuts',
));
$this
->assertTrue(!empty($link), 'Link Add to Default shortcuts found.');
// Test two pages which use same route name but different route parameters.
$this
->drupalGet('node/add/page');
// Add Shortcut for Basic Page.
$this
->clickLink('Add to Default shortcuts');
$this
->assertText('Added a shortcut for Create Basic page.');
// Assure that Article does not have its shortcut indicated as set.
$this
->drupalGet('node/add/article');
$link = $this
->xpath('//a[normalize-space()=:label]', array(
':label' => 'Remove from Default shortcuts',
));
$this
->assertTrue(empty($link), 'Link Remove to Default shortcuts not found for Create Article page.');
// Add Shortcut for Article.
$this
->clickLink('Add to Default shortcuts');
$this
->assertText('Added a shortcut for Create Article.');
}