You are here

protected function BasicTrackerTest::assertIndexingStatus in Search API 8

Asserts that the current tracking status is as expected.

Parameters

int $indexed: The expected number of indexed items.

int $total: The expected total number of items.

string|null $datasource_id: (optional) The datasource for which to check indexing status, or NULL to check for the whole index.

1 call to BasicTrackerTest::assertIndexingStatus()
BasicTrackerTest::testTracking in tests/src/Kernel/BasicTrackerTest.php
Tests tracking.

File

tests/src/Kernel/BasicTrackerTest.php, line 366

Class

BasicTrackerTest
Tests the "default" tracker plugin.

Namespace

Drupal\Tests\search_api\Kernel

Code

protected function assertIndexingStatus($indexed, $total, $datasource_id = NULL) {
  $datasource = $datasource_id ? " for datasource {$datasource_id}" : '';
  $actual_indexed = $this->tracker
    ->getIndexedItemsCount($datasource_id);
  $this
    ->assertEquals($indexed, $actual_indexed, "{$actual_indexed} items indexed{$datasource}, {$indexed} expected.");
  $actual_total = $this->tracker
    ->getTotalItemsCount($datasource_id);
  $this
    ->assertEquals($total, $actual_total, "{$actual_total} items tracked in total{$datasource}, {$total} expected.");
  $remaining = $total - $indexed;
  $actual_remaining = $this->tracker
    ->getRemainingItemsCount($datasource_id);
  $this
    ->assertEquals($remaining, $actual_remaining, "{$actual_remaining} items remaining to be indexed{$datasource}, {$remaining} expected.");
}