You are here

protected function IntegrationTest::changeProcessorFieldBoost in Search API 8

Tests that a field added by a processor can be changed.

For most fields added by processors, such as the "URL field" processor, only be the "Indexed" checkbox should be locked, not type and boost. This method verifies this.

2 calls to IntegrationTest::changeProcessorFieldBoost()
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 1255

Class

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

Namespace

Drupal\Tests\search_api\Functional

Code

protected function changeProcessorFieldBoost() {

  // Add the URL field.
  $this
    ->addField(NULL, 'search_api_url', 'URI');

  // Change the boost of the field.
  $fields_path = $this
    ->getIndexPath('fields');
  $this
    ->drupalGet($fields_path);
  $this
    ->submitForm([
    'fields[url][boost]' => Utility::formatBoostFactor(8),
  ], 'Save changes');
  $this
    ->assertSession()
    ->pageTextContains('The changes were successfully saved.');
  $option_field = $this
    ->assertSession()
    ->optionExists('edit-fields-url-boost', Utility::formatBoostFactor(8));
  $this
    ->assertTrue($option_field
    ->hasAttribute('selected'), 'Boost is correctly saved.');

  // Change the type of the field.
  $this
    ->drupalGet($fields_path);
  $this
    ->submitForm([
    'fields[url][type]' => 'text',
  ], 'Save changes');
  $this
    ->assertSession()
    ->pageTextContains('The changes were successfully saved.');
  $option_field = $this
    ->assertSession()
    ->optionExists('edit-fields-url-type', 'text');
  $this
    ->assertTrue($option_field
    ->hasAttribute('selected'), 'Type is correctly saved.');
}