public function IntegrationTest::testAllowOneActiveItem in Facets 8
Tests allow only one active item.
File
- tests/
src/ Functional/ IntegrationTest.php, line 516
Class
- IntegrationTest
- Tests the overall functionality of the Facets admin UI.
Namespace
Drupal\Tests\facets\FunctionalCode
public function testAllowOneActiveItem() {
$facet_name = 'Spotted wood owl';
$facet_id = 'spotted_wood_owl';
$facet_edit_page = 'admin/config/search/facets/' . $facet_id;
$this
->createFacet($facet_name, $facet_id, 'keywords');
$this
->drupalGet($facet_edit_page . '/edit');
$edit = [
'facet_settings[show_only_one_result]' => TRUE,
];
$this
->drupalPostForm(NULL, $edit, 'Save');
$this
->drupalGet('search-api-test-fulltext');
$this
->assertSession()
->pageTextContains('Displaying 5 search results');
$this
->assertFacetLabel('grape');
$this
->assertFacetLabel('orange');
$this
->clickLink('grape');
$this
->assertSession()
->pageTextContains('Displaying 3 search results');
$this
->checkFacetIsActive('grape');
$this
->assertFacetLabel('orange');
$this
->clickLink('orange');
$this
->assertSession()
->pageTextContains('Displaying 3 search results');
$this
->assertFacetLabel('grape');
$this
->checkFacetIsActive('orange');
}