function SearchMultilingualEntityTest::assertIndexCounts

Same name in other branches
  1. 9 core/modules/search/tests/src/Functional/SearchMultilingualEntityTest.php \Drupal\Tests\search\Functional\SearchMultilingualEntityTest::assertIndexCounts()
  2. 8.9.x core/modules/search/tests/src/Functional/SearchMultilingualEntityTest.php \Drupal\Tests\search\Functional\SearchMultilingualEntityTest::assertIndexCounts()
  3. 11.x core/modules/search/tests/src/Functional/SearchMultilingualEntityTest.php \Drupal\Tests\search\Functional\SearchMultilingualEntityTest::assertIndexCounts()

Verifies the indexing status counts.

@internal

Parameters

int $remaining: Count of remaining items to verify.

int $total: Count of total items to verify.

string $message: Message to use, something like "after updating the search index".

2 calls to SearchMultilingualEntityTest::assertIndexCounts()
SearchMultilingualEntityTest::setUp in core/modules/search/tests/src/Functional/SearchMultilingualEntityTest.php
SearchMultilingualEntityTest::testMultilingualSearch in core/modules/search/tests/src/Functional/SearchMultilingualEntityTest.php
Tests the indexing throttle and search results with multilingual nodes.

File

core/modules/search/tests/src/Functional/SearchMultilingualEntityTest.php, line 295

Class

SearchMultilingualEntityTest
Tests entities with multilingual fields.

Namespace

Drupal\Tests\search\Functional

Code

protected function assertIndexCounts(int $remaining, int $total, string $message) : void {
    // Check status via plugin method call.
    $status = $this->plugin
        ->indexStatus();
    $this->assertEquals($remaining, $status['remaining'], 'Remaining items ' . $message . ' is ' . $remaining);
    $this->assertEquals($total, $status['total'], 'Total items ' . $message . ' is ' . $total);
    // Check text in progress section of Search settings page. Note that this
    // test avoids using
    // \Drupal\Core\StringTranslation\TranslationInterface::formatPlural(), so
    // it tests for fragments of text.
    $indexed = $total - $remaining;
    $percent = $total > 0 ? floor(100 * $indexed / $total) : 100;
    $this->drupalGet('admin/config/search/pages');
    $this->assertSession()
        ->pageTextContains($percent . '% of the site has been indexed.');
    $this->assertSession()
        ->pageTextContains($remaining . ' item');
    // Check text in pages section of Search settings page.
    $this->assertSession()
        ->pageTextContains($indexed . ' of ' . $total . ' indexed');
    // Check text on status report page.
    $this->drupalGet('admin/reports/status');
    $this->assertSession()
        ->pageTextContains('Search index progress');
    $this->assertSession()
        ->pageTextContains($percent . '%');
    $this->assertSession()
        ->pageTextContains('(' . $remaining . ' remaining)');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.