function CommentFieldFilterTest::assertPageCounts
Same name in other branches
- 9 core/modules/comment/tests/src/Functional/Views/CommentFieldFilterTest.php \Drupal\Tests\comment\Functional\Views\CommentFieldFilterTest::assertPageCounts()
- 8.9.x core/modules/comment/tests/src/Functional/Views/CommentFieldFilterTest.php \Drupal\Tests\comment\Functional\Views\CommentFieldFilterTest::assertPageCounts()
- 10 core/modules/comment/tests/src/Functional/Views/CommentFieldFilterTest.php \Drupal\Tests\comment\Functional\Views\CommentFieldFilterTest::assertPageCounts()
Asserts that the given comment translation counts are correct.
@internal
Parameters
string $path: Path of the page to test.
array $counts: Array whose keys are languages, and values are the number of times that translation should be shown on the given page.
string $message: Message suffix to display.
1 call to CommentFieldFilterTest::assertPageCounts()
- CommentFieldFilterTest::testFilters in core/
modules/ comment/ tests/ src/ Functional/ Views/ CommentFieldFilterTest.php - Tests body and title filters.
File
-
core/
modules/ comment/ tests/ src/ Functional/ Views/ CommentFieldFilterTest.php, line 119
Class
- CommentFieldFilterTest
- Tests comment field filters with translations.
Namespace
Drupal\Tests\comment\Functional\ViewsCode
protected function assertPageCounts(string $path, array $counts, string $message) : void {
// Get the text of the page.
$this->drupalGet($path);
$text = $this->getTextContent();
// Check the counts. Note that the title and body are both shown on the
// page, and they are the same. So the title/body string should appear on
// the page twice as many times as the input count.
foreach ($counts as $langcode => $count) {
$this->assertEquals(2 * $count, substr_count($text, $this->commentTitles[$langcode]), 'Translation ' . $langcode . ' has count ' . $count . ' with ' . $message);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.