function BlockContentFieldFilterTest::assertPageCounts

Same name and namespace in other branches
  1. 8.9.x core/modules/block_content/tests/src/Functional/Views/BlockContentFieldFilterTest.php \Drupal\Tests\block_content\Functional\Views\BlockContentFieldFilterTest::assertPageCounts()
  2. 10 core/modules/block_content/tests/src/Functional/Views/BlockContentFieldFilterTest.php \Drupal\Tests\block_content\Functional\Views\BlockContentFieldFilterTest::assertPageCounts()
  3. 11.x core/modules/block_content/tests/src/Functional/Views/BlockContentFieldFilterTest.php \Drupal\Tests\block_content\Functional\Views\BlockContentFieldFilterTest::assertPageCounts()

Asserts that the given block_content 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 BlockContentFieldFilterTest::assertPageCounts()
BlockContentFieldFilterTest::testFilters in core/modules/block_content/tests/src/Functional/Views/BlockContentFieldFilterTest.php
Tests body and info filters.

File

core/modules/block_content/tests/src/Functional/Views/BlockContentFieldFilterTest.php, line 105

Class

BlockContentFieldFilterTest
Tests block_content field filters with translations.

Namespace

Drupal\Tests\block_content\Functional\Views

Code

protected function assertPageCounts(string $path, array $counts, string $message) : void {
    // Get the text of the page.
    $this->drupalGet($path);
    $text = $this->getTextContent();
    foreach ($counts as $langcode => $count) {
        $this->assertEquals($count, substr_count($text, $this->blockContentInfos[$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.