function CommentPagerTest::assertCommentOrder
Same name in other branches
- 9 core/modules/comment/tests/src/Functional/CommentPagerTest.php \Drupal\Tests\comment\Functional\CommentPagerTest::assertCommentOrder()
- 8.9.x core/modules/comment/tests/src/Functional/CommentPagerTest.php \Drupal\Tests\comment\Functional\CommentPagerTest::assertCommentOrder()
- 10 core/modules/comment/tests/src/Functional/CommentPagerTest.php \Drupal\Tests\comment\Functional\CommentPagerTest::assertCommentOrder()
- 11.x core/modules/comment/tests/src/Functional/CommentPagerTest.php \Drupal\Tests\comment\Functional\CommentPagerTest::assertCommentOrder()
Helper function: assert that the comments are displayed in the correct order.
Parameters
$comments: And array of comments.
$expected_order: An array of keys from $comments describing the expected order.
1 call to CommentPagerTest::assertCommentOrder()
- CommentPagerTest::testCommentOrderingThreading in modules/
comment/ comment.test - Test comment ordering and threading.
File
-
modules/
comment/ comment.test, line 1399
Class
- CommentPagerTest
- Verify pagination of comments.
Code
function assertCommentOrder(array $comments, array $expected_order) {
$expected_cids = array();
// First, rekey the expected order by cid.
foreach ($expected_order as $key) {
$expected_cids[] = $comments[$key]->id;
}
$comment_anchors = $this->xpath('//a[starts-with(@id,"comment-")]');
$result_order = array();
foreach ($comment_anchors as $anchor) {
$result_order[] = substr($anchor['id'], 8);
}
return $this->assertIdentical($expected_cids, $result_order, format_string('Comment order: expected @expected, returned @returned.', array(
'@expected' => implode(',', $expected_cids),
'@returned' => implode(',', $result_order),
)));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.