public function IndexFormTest::internalTestConfirmForm in Elasticsearch Connector Autocomplete 8
Tests confirm form behaviour.
1 call to IndexFormTest::internalTestConfirmForm()
- IndexFormTest::testFormBehaviour in tests/
src/ FunctionalJavascript/ IndexFormTest.php - Tests confirm form behaviour.
File
- tests/
src/ FunctionalJavascript/ IndexFormTest.php, line 85
Class
- IndexFormTest
- Defines a class for testing the form modifications.
Namespace
Drupal\Tests\elasticsearch_connector_autocomp\FunctionalJavascriptCode
public function internalTestConfirmForm() {
/** @var \Drupal\search_api\IndexInterface $index */
$indexStorage = $this->container
->get('entity_type.manager')
->getStorage('search_api_index');
$index = $indexStorage
->load('elasticsearch_index');
// Assert that the ngram filter is disabled in configuration.
$this
->assertFalse($index
->getThirdPartySetting('elasticsearch_connector', 'ngram_filter_enabled', FALSE));
// Tests the ngram filter check box exists on our form.
$this
->drupalGet($index
->toUrl('edit-form'));
$assert = $this
->assertSession();
$assert
->fieldExists('third_party_settings[elasticsearch_connector][ngram_filter_enabled]');
// If the fieldset isn't open, webdriver gets upset when the form is
// submitted. "field isn't visible" error.
// Open the fieldset.
$node = $this
->getSession()
->getPage()
->find('css', "#edit-third-party-settings-elasticsearch-connector");
$node
->click();
$this
->submitForm([
'name' => 'A new name for the index',
'third_party_settings[elasticsearch_connector][ngram_filter_enabled]' => 1,
], 'Save');
// Flag should still be disabled at this stage.
$indexStorage
->resetCache();
$index = $indexStorage
->load('elasticsearch_index');
$this
->assertFalse($index
->getThirdPartySetting('elasticsearch_connector', 'ngram_filter_enabled', FALSE));
// And the name should be unchanged.
$this
->assertEquals('Test index using elasticsearch module', $index
->label());
// Should be a confirm form.
$assert
->pageTextContains('You are changing the analyzer on an existing index.');
$assert
->pageTextContains('This will result in the index being deleted and rebuilt and you will have to reindex all items. Are you sure you want to continue?');
// Submit the confirm form.
$this
->submitForm([], 'Confirm');
// Flag should now be set.
$indexStorage
->resetCache();
$index = $indexStorage
->load('elasticsearch_index');
$this
->assertNotEmpty($index
->getThirdPartySetting('elasticsearch_connector', 'ngram_filter_enabled', FALSE));
// And the name should be changed.
$this
->assertEquals('A new name for the index', $index
->label());
$this
->internalTestTaxonomyIndex($indexStorage);
}