You are here

protected function SearchMultilingualEntityTest::assertIndexCounts in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/search/tests/src/Functional/SearchMultilingualEntityTest.php \Drupal\Tests\search\Functional\SearchMultilingualEntityTest::assertIndexCounts()

Verifies the indexing status counts.

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 288

Class

SearchMultilingualEntityTest
Tests entities with multilingual fields.

Namespace

Drupal\Tests\search\Functional

Code

protected function assertIndexCounts($remaining, $total, $message) {

  // 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)');
}