Issue #2642260 by gnuget, gargsuchi, naveenvalecha, dinarcon: Missing URL fragment for the comment's title link

8.3.x
Nathaniel Catchpole 2016-08-30 14:34:08 +01:00
parent df34f696f0
commit 0515e65bd5
2 changed files with 7 additions and 1 deletions

View File

@ -657,7 +657,7 @@ function template_preprocess_comment(&$variables) {
$variables['permalink'] = \Drupal::l(t('Permalink'), new Url('<front>'));
}
else {
$uri = $comment->urlInfo();
$uri = $comment->permalink();
$attributes = $uri->getOption('attributes') ?: array();
$attributes += array('class' => array('permalink'), 'rel' => 'bookmark');
$uri->setOption('attributes', $attributes);

View File

@ -59,6 +59,12 @@ class CommentTitleTest extends CommentTestBase {
$this->assertTrue($this->commentExists($comment1), 'Comment #1. Comment found.');
// Tests that markup is created for comment with heading.
$this->assertPattern('|<h3[^>]*><a[^>]*>' . $subject_text . '</a></h3>|', 'Comment title is rendered in h3 when title populated.');
// Tests that the comment's title link is the permalink of the comment.
$comment_permalink = $this->cssSelect('.permalink');
$comment_permalink = (string) $comment_permalink[0]['href'];
// Tests that the comment's title link contains the url fragment.
$this->assertTrue(strpos($comment_permalink, '#comment-' . $comment1->id()), "The comment's title link contains the url fragment.");
$this->assertEqual($comment1->permalink()->toString(), $comment_permalink, "The comment's title has the correct link.");
}
}