diff --git a/core/modules/comment/src/Tests/CommentTitleTest.php b/core/modules/comment/src/Tests/CommentTitleTest.php
index afdccaf..9e59da1 100644
--- a/core/modules/comment/src/Tests/CommentTitleTest.php
+++ b/core/modules/comment/src/Tests/CommentTitleTest.php
@@ -65,9 +65,8 @@ public function testCommentPopulatedTitles() {
// Tests that markup is created for comment with heading.
$this->assertPattern('|
|', 'Comment title is rendered in h3 when title populated.');
// Tests that the comment's title has the correct link.
- $comment_id = $comment1->id();
$comment_permalink = $this->cssSelect('.permalink');
- $comment_permalink = (string)$comment_permalink[0]->attributes()->{'href'};
- $this->assertTrue($comment_permalink === '/comment/' . $comment_id . '#comment-' . $comment_id, 'The comment\'s title has the correct link');
+ $comment_permalink = (string)$comment_permalink[0]['href'];
+ $this->assertTrue((bool)preg_match('/\/comment\/[0-9]+#comment\-[0-9]+/', $comment_permalink), 'The comment\'s title has the correct link');
}
}