public function IntegrationTest::testMinimumAmount in Facets 8
Test minimum amount of items.
File
- tests/
src/ Functional/ IntegrationTest.php, line 698
Class
- IntegrationTest
- Tests the overall functionality of the Facets admin UI.
Namespace
Drupal\Tests\facets\FunctionalCode
public function testMinimumAmount() {
$id = "elf_owl";
$name = "Elf owl";
$this
->createFacet($name, $id);
// Show the amount of items.
$edit = [
'widget' => 'links',
'widget_config[show_numbers]' => '1',
'facet_settings[min_count]' => 1,
];
$this
->drupalPostForm('admin/config/search/facets/elf_owl/edit', $edit, 'Save');
// See that both article and item are showing.
$this
->drupalGet('search-api-test-fulltext');
$this
->assertSession()
->pageTextContains('Displaying 5 search results');
$this
->assertFacetLabel('article (2)');
$this
->assertFacetLabel('item (3)');
// Make sure that a facet needs at least 3 results.
$edit = [
'widget' => 'links',
'widget_config[show_numbers]' => '1',
'facet_settings[min_count]' => 3,
];
$this
->drupalPostForm('admin/config/search/facets/elf_owl/edit', $edit, 'Save');
// See that article is now hidden, item should still be showing.
$this
->drupalGet('search-api-test-fulltext');
$this
->assertSession()
->pageTextContains('Displaying 5 search results');
$this
->assertSession()
->pageTextNotContains('article');
$this
->assertFacetLabel('item (3)');
}