public function IntegrationTest::testExcludeFacet in Facets 8
Tests the facet's exclude functionality.
File
- tests/
src/ Functional/ IntegrationTest.php, line 409
Class
- IntegrationTest
- Tests the overall functionality of the Facets admin UI.
Namespace
Drupal\Tests\facets\FunctionalCode
public function testExcludeFacet() {
$facet_name = 'test & facet';
$facet_id = 'test_facet';
$facet_edit_page = 'admin/config/search/facets/' . $facet_id . '/edit';
$this
->createFacet($facet_name, $facet_id);
$this
->drupalGet($facet_edit_page);
$this
->assertSession()
->checkboxNotChecked('edit-facet-settings-exclude');
$this
->drupalPostForm(NULL, [
'facet_settings[exclude]' => TRUE,
], 'Save');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->checkboxChecked('edit-facet-settings-exclude');
$this
->drupalGet('search-api-test-fulltext');
$this
->assertSession()
->pageTextContains('foo bar baz');
$this
->assertSession()
->pageTextContains('foo baz');
$this
->assertFacetLabel('item');
$this
->clickLink('item');
$this
->checkFacetIsActive('item');
$this
->assertSession()
->pageTextContains('foo baz');
$this
->assertSession()
->pageTextContains('bar baz');
$this
->assertSession()
->pageTextNotContains('foo bar baz');
$this
->drupalGet($facet_edit_page);
$this
->drupalPostForm(NULL, [
'facet_settings[exclude]' => FALSE,
], 'Save');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->checkboxNotChecked('edit-facet-settings-exclude');
$this
->drupalGet('search-api-test-fulltext');
$this
->assertSession()
->pageTextContains('foo bar baz');
$this
->assertSession()
->pageTextContains('foo baz');
$this
->assertFacetLabel('item');
$this
->clickLink('item');
$this
->checkFacetIsActive('item');
$this
->assertSession()
->pageTextContains('foo bar baz');
$this
->assertSession()
->pageTextContains('foo test');
$this
->assertSession()
->pageTextContains('bar');
$this
->assertSession()
->pageTextNotContains('foo baz');
}