You are here

public function RestIntegrationTest::testWidgetSelection in Facets 8

Tests that the system raises an error when selecting the wrong widget.

File

modules/facets_rest/tests/src/Functional/RestIntegrationTest.php, line 306

Class

RestIntegrationTest
Tests the integration of REST-views and facets.

Namespace

Drupal\Tests\facets_rest\Functional

Code

public function testWidgetSelection() {
  $id = 'type';

  // Add a new facet to filter by content type.
  $this
    ->createFacet('Type', $id, 'type', 'rest_export_1', 'views_rest__search_api_rest_test_view');

  // Use the array widget.
  $facet_edit_page = '/admin/config/search/facets/' . $id . '/edit';
  $this
    ->drupalGet($facet_edit_page);
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->drupalPostForm(NULL, [
    'widget' => 'checkbox',
  ], 'Configure widget');
  $this
    ->assertSession()
    ->pageTextContains('The Facet source is a Rest export. Please select a raw widget.');
  $this
    ->drupalPostForm(NULL, [
    'widget' => 'array',
  ], 'Configure widget');
  $this
    ->assertSession()
    ->pageTextNotContains('The Facet source is a Rest export. Please select a raw widget.');
}