You are here

protected function SearchMultilingualEntityTest::assertDatabaseCounts 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::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/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 307
Contains \Drupal\search\Tests\SearchMultilingualEntityTest.

Class

SearchMultilingualEntityTest
Tests entities with multilingual fields.

Namespace

Drupal\search\Tests

Code

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

  // Count number of distinct nodes by ID.
  $results = db_select('search_dataset', 'i')
    ->fields('i', array(
    'sid',
  ))
    ->condition('type', 'node_search')
    ->groupBy('sid')
    ->execute()
    ->fetchCol();
  $this
    ->assertEqual($count_node, count($results), 'Node count was ' . $count_node . ' for ' . $message);

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