You are here

protected function IntegrationTest::removeFieldsDependencies in Search API 8

Tests whether removing fields on which the index depends works correctly.

1 call to IntegrationTest::removeFieldsDependencies()
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 1035

Class

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

Namespace

Drupal\Tests\search_api\Functional

Code

protected function removeFieldsDependencies() {

  // Remove a field and make sure that doing so does not remove the search
  // index.
  $this
    ->drupalGet('admin/structure/types/manage/article/fields/node.article.field_link/delete');
  $this
    ->assertSession()
    ->pageTextNotContains('The listed configuration will be deleted.');
  $this
    ->assertSession()
    ->pageTextContains('Search index');
  $this
    ->submitForm([], 'Delete');
  $this
    ->drupalGet('admin/structure/types/manage/article/fields/node.article.field_image/delete');
  $this
    ->submitForm([], 'Delete');
  $this
    ->assertNotNull($this
    ->getIndex(), 'Index was not deleted.');
  $this
    ->drupalGet($this
    ->getIndexPath('fields'));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextNotContains('field_link');
  $this
    ->assertSession()
    ->fieldExists('fields[field_image][id]');
  $this
    ->assertSession()
    ->fieldValueEquals('fields[field_image][id]', 'field_image');
  $field_dependencies = \Drupal::config('search_api.index.' . $this->indexId)
    ->get('dependencies.config');
  $this
    ->assertFalse(in_array('field.storage.node.field_link', (array) $field_dependencies), "The link field has been removed from the index's dependencies.");
  $this
    ->assertTrue(in_array('field.storage.node.field_image', (array) $field_dependencies), "The image field has been removed from the index's dependencies.");
}