function SearchMultilingualEntityTest::assertDatabaseCounts
Same name in other branches
- 9 core/modules/search/tests/src/Functional/SearchMultilingualEntityTest.php \Drupal\Tests\search\Functional\SearchMultilingualEntityTest::assertDatabaseCounts()
- 10 core/modules/search/tests/src/Functional/SearchMultilingualEntityTest.php \Drupal\Tests\search\Functional\SearchMultilingualEntityTest::assertDatabaseCounts()
- 11.x 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 322
Class
- SearchMultilingualEntityTest
- Tests entities with multilingual fields.
Namespace
Drupal\Tests\search\FunctionalCode
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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.