You are here

public function WidgetIntegrationTest::testSupportsFacet in Facets 8

Tests the facet support for a widget.

File

tests/src/Functional/WidgetIntegrationTest.php, line 158

Class

WidgetIntegrationTest
Tests the overall functionality of the Facets admin UI.

Namespace

Drupal\Tests\facets\Functional

Code

public function testSupportsFacet() {
  $id = 'masked_owl';
  $this
    ->createFacet('Australian masked owl', $id);

  // Go to the facet edit page and check to see if the custom widget shows
  // up.
  $this
    ->drupalGet('admin/config/search/facets/' . $id . '/edit');
  $this
    ->assertSession()
    ->pageTextContains('Custom widget');

  // Make the ::supportsFacet method on the custom widget return false.
  \Drupal::state()
    ->set('facets_test_supports_facet', FALSE);

  // Go to the facet edit page and check to see if the custom widget is now
  // hidden.
  $this
    ->drupalGet('admin/config/search/facets/' . $id . '/edit');
  $this
    ->assertSession()
    ->pageTextNotContains('Custom widget');
}