You are here

protected function IntegrationTest::createIndexDuplicate in Search API 8

Tests creating a search index with an existing machine name.

1 call to IntegrationTest::createIndexDuplicate()
IntegrationTest::testFramework in tests/src/Functional/IntegrationTest.php
Tests various operations via the Search API's admin UI.

File

tests/src/Functional/IntegrationTest.php, line 375

Class

IntegrationTest
Tests the overall functionality of the Search API framework and admin UI.

Namespace

Drupal\Tests\search_api\Functional

Code

protected function createIndexDuplicate() {
  $index_add_page = 'admin/config/search/search-api/add-index';
  $this
    ->drupalGet($index_add_page);
  $edit = [
    'name' => $this->indexId,
    'id' => $this->indexId,
    'server' => $this->serverId,
    'datasources[entity:node]' => TRUE,
  ];

  // Try to submit an index with a duplicate machine name.
  $this
    ->submitForm($edit, 'Save');
  $this
    ->assertSession()
    ->pageTextContains('The machine-readable name is already in use. It must be unique.');

  // Try to submit an index with a duplicate machine name after form
  // rebuilding via datasource submit.
  $this
    ->submitForm($edit, 'datasources_configure');
  $this
    ->submitForm($edit, 'Save');
  $this
    ->assertSession()
    ->pageTextContains('The machine-readable name is already in use. It must be unique.');

  // Try to submit an index with a duplicate machine name after form
  // rebuilding via datasource submit using AJAX.
  $this
    ->submitForm($edit, 'datasources_configure');
  $this
    ->submitForm($edit, 'Save');
  $this
    ->assertSession()
    ->pageTextContains('The machine-readable name is already in use. It must be unique.');
}