// Click the reindex button on the admin page, verify counts, and reindex.
$this->
drupalGet('admin/config/search/pages'
);
$this->
submitForm([], 'Re-index site'
);
$this->
submitForm([], 'Re-index site'
);
$this->
assertIndexCounts(8, 8, 'after reindex'
);
$this->
assertDatabaseCounts(8, 0, 'after reindex'
);
$this->plugin->
updateIndex();
// Test search results.
// This should find two results for the second and third node.
$this->plugin->
setSearch('English OR Hungarian',
[],
[]);
$search_result =
$this->plugin->
execute();
$this->
assertCount(2,
$search_result, 'Found two results.'
);
// Nodes are saved directly after each other and have the same created time
// so testing for the order is not possible.
$results =
[$search_result[0
]['title'
],
$search_result[1
]['title'
]];
$this->
assertContains('Third node this is the Hungarian title',
$results, 'The search finds the correct Hungarian title.'
);
$this->
assertContains('Second node this is the English title',
$results, 'The search finds the correct English title.'
);
// Now filter for Hungarian results only.
$this->plugin->
setSearch('English OR Hungarian',
['f' =>
['language:hu'
]],
[]);
$search_result =
$this->plugin->
execute();