You are here

protected function SearchMultilingualEntityTest::assertDatabaseCounts 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::assertDatabaseCounts()

Checks actual database counts of items in the search index.

Parameters

int $count_node: Count of node items to assert.

int $count_foo: Count of "foo" items to assert.

string $message: Message suffix to use.

2 calls to SearchMultilingualEntityTest::assertDatabaseCounts()
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 324

Class

SearchMultilingualEntityTest
Tests entities with multilingual fields.

Namespace

Drupal\Tests\search\Functional

Code

protected function assertDatabaseCounts($count_node, $count_foo, $message) {

  // Count number of distinct nodes by ID.
  $connection = Database::getConnection();
  $results = $connection
    ->select('search_dataset', 'i')
    ->fields('i', [
    'sid',
  ])
    ->condition('type', 'node_search')
    ->groupBy('sid')
    ->execute()
    ->fetchCol();
  $this
    ->assertCount($count_node, $results, 'Node count was ' . $count_node . ' for ' . $message);

  // Count number of "foo" records.
  $results = $connection
    ->select('search_dataset', 'i')
    ->fields('i', [
    'sid',
  ])
    ->condition('type', 'foo')
    ->execute()
    ->fetchCol();
  $this
    ->assertCount($count_foo, $results, 'Foo count was ' . $count_foo . ' for ' . $message);
}