public function IntegrationTest::testFacetSourceVisibility in Facets 8
Tests the visibility of facet source.
File
- tests/
src/ Functional/ IntegrationTest.php, line 735
Class
- IntegrationTest
- Tests the overall functionality of the Facets admin UI.
Namespace
Drupal\Tests\facets\FunctionalCode
public function testFacetSourceVisibility() {
$this
->createFacet('Vicuña', 'vicuna');
$edit = [
'facet_settings[only_visible_when_facet_source_is_visible]' => FALSE,
];
$this
->drupalPostForm('/admin/config/search/facets/vicuna/edit', $edit, 'Save');
// Test that the facet source is visible on the search page and user/2 page.
$this
->drupalGet('search-api-test-fulltext');
$this
->assertFacetBlocksAppear();
$this
->drupalGet('user/2');
$this
->assertFacetBlocksAppear();
// Change the facet to only show when it's source is visible.
$edit = [
'facet_settings[only_visible_when_facet_source_is_visible]' => TRUE,
];
$this
->drupalPostForm('/admin/config/search/facets/vicuna/edit', $edit, 'Save');
// Test that the facet still apears on the search page but is hidden on the
// user page.
$this
->drupalGet('search-api-test-fulltext');
$this
->assertFacetBlocksAppear();
$this
->drupalGet('user/2');
$this
->assertNoFacetBlocksAppear();
}