You are here

protected function SearchMultilingualEntityTest::assertIndexCounts in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/search/src/Tests/SearchMultilingualEntityTest.php \Drupal\search\Tests\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/src/Tests/SearchMultilingualEntityTest.php
Sets up a Drupal site for running functional and integration tests.
SearchMultilingualEntityTest::testMultilingualSearch in core/modules/search/src/Tests/SearchMultilingualEntityTest.php
Tests the indexing throttle and search results with multilingual nodes.

File

core/modules/search/src/Tests/SearchMultilingualEntityTest.php, line 271
Contains \Drupal\search\Tests\SearchMultilingualEntityTest.

Class

SearchMultilingualEntityTest
Tests entities with multilingual fields.

Namespace

Drupal\search\Tests

Code

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

  // Check status via plugin method call.
  $status = $this->plugin
    ->indexStatus();
  $this
    ->assertEqual($status['remaining'], $remaining, 'Remaining items ' . $message . ' is ' . $remaining);
  $this
    ->assertEqual($status['total'], $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
    ->assertText($percent . '% of the site has been indexed.', 'Progress percent text at top of Search settings page is correct at: ' . $message);
  $this
    ->assertText($remaining . ' item', 'Remaining text at top of Search settings page is correct at: ' . $message);

  // Check text in pages section of Search settings page.
  $this
    ->assertText($indexed . ' of ' . $total . ' indexed', 'Progress text in pages section of Search settings page is correct at: ' . $message);

  // Check text on status report page.
  $this
    ->drupalGet('admin/reports/status');
  $this
    ->assertText('Search index progress', 'Search status section header is present on status report page');
  $this
    ->assertText($percent . '%', 'Correct percentage is shown on status report page at: ' . $message);
  $this
    ->assertText('(' . $remaining . ' remaining)', 'Correct remaining value is shown on status report page at: ' . $message);
}