You are here

public function ProcessorIntegrationTest::testLimitProcessors in Search API 8

Tests that processors discouraged by the backend are correctly hidden.

See also

https://www.drupal.org/node/2228739

File

tests/src/Functional/ProcessorIntegrationTest.php, line 290

Class

ProcessorIntegrationTest
Tests the admin UI for processors.

Namespace

Drupal\Tests\search_api\Functional

Code

public function testLimitProcessors() {
  $this
    ->loadProcessorsTab();
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextContains('Highlight');
  $this
    ->assertSession()
    ->pageTextContains('Ignore character');
  $this
    ->assertSession()
    ->pageTextContains('Tokenizer');
  $this
    ->assertSession()
    ->pageTextContains('Stopwords');

  // Create a new server with the "search_api_test" backend.
  $server = Server::create([
    'id' => 'webtest_server',
    'name' => 'WebTest server',
    'description' => 'WebTest server',
    'backend' => 'search_api_test',
    'backend_config' => [],
  ]);
  $server
    ->save();
  $processors = [
    'highlight',
    'ignore_character',
    'tokenizer',
    'stopwords',
  ];
  $this
    ->setReturnValue('backend', 'getDiscouragedProcessors', $processors);

  // Use the newly created server.
  $settings_path = 'admin/config/search/search-api/index/' . $this->indexId . '/edit';
  $this
    ->drupalGet($settings_path);
  $this
    ->submitForm([
    'server' => 'webtest_server',
  ], 'Save');

  // Load the processors again and check that they are disabled now.
  $this
    ->loadProcessorsTab();
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextContains('It is recommended not to use this processor with the selected server.');
  $this
    ->assertSession()
    ->elementExists('css', 'input[name="status[highlight]"][disabled="disabled"]');
  $this
    ->assertSession()
    ->elementExists('css', 'input[name="status[ignore_character]"][disabled="disabled"]');
  $this
    ->assertSession()
    ->elementExists('css', 'input[name="status[tokenizer]"][disabled="disabled"]');
  $this
    ->assertSession()
    ->elementExists('css', 'input[name="status[stopwords]"][disabled="disabled"]');
}