Update to Drupal 8.2.2. For more information, see https://www.drupal.org/project/drupal/releases/8.2.2
This commit is contained in:
parent
23ffed3665
commit
507b45a0ed
378 changed files with 11434 additions and 5542 deletions
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace Drupal\shortcut\Tests;
|
||||
|
||||
use Drupal\block_content\Entity\BlockContentType;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\shortcut\Entity\Shortcut;
|
||||
use Drupal\shortcut\Entity\ShortcutSet;
|
||||
|
|
@ -161,18 +163,12 @@ class ShortcutLinksTest extends ShortcutTestBase {
|
|||
// 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.');
|
||||
$this->assertShortcutQuickLink('Remove from Default shortcuts');
|
||||
|
||||
// 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.');
|
||||
$this->assertShortcutQuickLink('Add to Default shortcuts');
|
||||
|
||||
// Test two pages which use same route name but different route parameters.
|
||||
$this->drupalGet('node/add/page');
|
||||
|
|
@ -186,6 +182,37 @@ class ShortcutLinksTest extends ShortcutTestBase {
|
|||
// Add Shortcut for Article.
|
||||
$this->clickLink('Add to Default shortcuts');
|
||||
$this->assertText('Added a shortcut for Create Article.');
|
||||
|
||||
$this->config('system.theme')->set('default', 'seven')->save();
|
||||
$this->drupalGet('node/' . $this->node->id());
|
||||
$title = $this->node->getTitle();
|
||||
|
||||
// Test the "Add to shortcuts" link for node view route.
|
||||
$this->clickLink('Add to Default shortcuts');
|
||||
$this->assertText(new FormattableMarkup('Added a shortcut for @title.', ['@title' => $title]));
|
||||
$this->assertShortcutQuickLink('Remove from Default shortcuts');
|
||||
|
||||
// Test the "Remove from shortcuts" link for node view route.
|
||||
$this->clickLink('Remove from Default shortcuts');
|
||||
$this->assertText(new FormattableMarkup('The shortcut @title has been deleted.', ['@title' => $title]));
|
||||
$this->assertShortcutQuickLink('Add to Default shortcuts');
|
||||
|
||||
\Drupal::service('module_installer')->install(['block_content']);
|
||||
BlockContentType::create(array(
|
||||
'id' => 'basic',
|
||||
'label' => 'Basic block',
|
||||
'revision' => FALSE,
|
||||
))->save();
|
||||
// Test page with HTML tags in title.
|
||||
$this->drupalGet('admin/structure/block/block-content/manage/basic');
|
||||
$page_title = new FormattableMarkup('Edit %label custom block type', ['%label' => 'Basic block']);
|
||||
$this->assertRaw($page_title);
|
||||
// Add shortcut to this page.
|
||||
$this->clickLink('Add to Default shortcuts');
|
||||
$this->assertRaw(new FormattableMarkup('Added a shortcut for %title.', [
|
||||
'%title' => trim(strip_tags($page_title)),
|
||||
]));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -404,4 +431,32 @@ class ShortcutLinksTest extends ShortcutTestBase {
|
|||
$this->assertNoBlockAppears($block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes if a shortcut quick link with the specified label is found.
|
||||
*
|
||||
* An optional link index may be passed.
|
||||
*
|
||||
* @param string $label
|
||||
* Text between the anchor tags.
|
||||
* @param int $index
|
||||
* Link position counting from zero.
|
||||
* @param string $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use format_string() to embed variables in the message text, not
|
||||
* t(). If left blank, a default message will be displayed.
|
||||
* @param string $group
|
||||
* (optional) The group this message is in, which is displayed in a column
|
||||
* in test output. Use 'Debug' to indicate this is debugging output. Do not
|
||||
* translate this string. Defaults to 'Other'; most tests do not override
|
||||
* this default.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the assertion succeeded, FALSE otherwise.
|
||||
*/
|
||||
protected function assertShortcutQuickLink($label, $index = 0, $message = '', $group = 'Other') {
|
||||
$links = $this->xpath('//a[normalize-space()=:label]', array(':label' => $label));
|
||||
$message = ($message ? $message : SafeMarkup::format('Shortcut quick link with label %label found.', array('%label' => $label)));
|
||||
return $this->assert(isset($links[$index]), $message, $group);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue