You are here

public function IndexFormTest::internalTestTaxonomyIndex in Elasticsearch Connector Autocomplete 8

Tests showing fields for taxonomy based indices.

2 calls to IndexFormTest::internalTestTaxonomyIndex()
IndexFormTest::internalTestConfirmForm in tests/src/FunctionalJavascript/IndexFormTest.php
Tests confirm form behaviour.
IndexFormTest::testFormBehaviour in tests/src/FunctionalJavascript/IndexFormTest.php
Tests confirm form behaviour.

File

tests/src/FunctionalJavascript/IndexFormTest.php, line 136

Class

IndexFormTest
Defines a class for testing the form modifications.

Namespace

Drupal\Tests\elasticsearch_connector_autocomp\FunctionalJavascript

Code

public function internalTestTaxonomyIndex() {

  /** @var \Drupal\search_api\IndexInterface $index */
  $indexStorage = $this->container
    ->get('entity_type.manager')
    ->getStorage('search_api_index');

  // Test hook_form_search_api_index_fields_alter, see issue #3006322.
  $index = $indexStorage
    ->load('taxonomy_term_index');
  $this
    ->drupalGet($index
    ->toUrl('fields'));
  $assert = $this
    ->assertSession();
  $assert
    ->optionExists('fields[name][type]', 'text_ngram');
  $field_name = $this
    ->xpath('//select[@id="edit-fields-name-boost"]');
  $states = (array) json_decode($field_name[0]
    ->getAttribute('data-drupal-states'), TRUE);
  $field_visible = $states['visible'][':input[name="fields[name][type]"]'];
  $values = array_column($field_visible, 'value');
  $this
    ->assertContains('text_ngram', $values, 'Field "name" updated in elasticsearch_connector_autocomp_form_search_api_index_fields_alter()');
}