You are here

protected function IntegrationTest::removeFieldsFromIndex in Search API 8

Tests whether removing fields from the index works correctly.

2 calls to IntegrationTest::removeFieldsFromIndex()
IntegrationTest::testFramework in tests/src/Functional/IntegrationTest.php
Tests various operations via the Search API's admin UI.
IntegrationTest::testIntegerIndex in tests/src/Functional/IntegrationTest.php
Tests what happens when an index has an integer as id/label.

File

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

Class

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

Namespace

Drupal\Tests\search_api\Functional

Code

protected function removeFieldsFromIndex() {

  // Find the "Remove" link for the "body" field.
  $links = $this
    ->xpath('//a[@data-drupal-selector=:id]', [
    ':id' => 'edit-fields-body-remove',
  ]);
  $this
    ->assertNotEmpty($links, 'Found "Remove" link for body field');
  $this
    ->assertIsArray($links);
  $url_target = $this
    ->getAbsoluteUrl($links[0]
    ->getAttribute('href'));
  $this
    ->drupalGet($url_target);
  $this
    ->drupalGet($this
    ->getIndexPath('fields'));
  $this
    ->submitForm([], 'Save changes');
  $index = $this
    ->getIndex(TRUE);
  $fields = $index
    ->getFields();
  $this
    ->assertArrayNotHasKey('body', $fields);
}