You are here

public function ProcessorIntegrationTest::checkContentAccessIntegration in Search API 8

Tests the UI for the "Content access" processor.

1 call to ProcessorIntegrationTest::checkContentAccessIntegration()
ProcessorIntegrationTest::testProcessorIntegration in tests/src/Functional/ProcessorIntegrationTest.php
Tests the admin UI for processors.

File

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

Class

ProcessorIntegrationTest
Tests the admin UI for processors.

Namespace

Drupal\Tests\search_api\Functional

Code

public function checkContentAccessIntegration() {
  $this
    ->enableProcessor('content_access');

  // Ensure the fields required for the "Content access" processor are now
  // indexed.
  $index = $this
    ->loadIndex();
  $index
    ->save();
  $content_access_fields = [
    'status' => [
      'datasource_id' => 'entity:node',
      'property_path' => 'status',
      'type' => 'boolean',
      'indexed_locked' => TRUE,
      'type_locked' => TRUE,
    ],
    'uid' => [
      'datasource_id' => 'entity:node',
      'property_path' => 'uid',
      'type' => 'integer',
      'indexed_locked' => TRUE,
      'type_locked' => TRUE,
    ],
    'node_grants' => [
      'property_path' => 'search_api_node_grants',
      'type' => 'string',
      'indexed_locked' => TRUE,
      'type_locked' => TRUE,
      'hidden' => TRUE,
    ],
  ];
  $index_fields = $index
    ->getFields();
  foreach ($content_access_fields as $field_id => $settings) {
    $this
      ->assertTrue(!empty($index_fields[$field_id]), "Field {$field_id} (required by \"Content access\" processor) is present.");
    $field_settings = $index_fields[$field_id]
      ->getSettings();
    unset($field_settings['label'], $field_settings['dependencies']);
    $this
      ->assertEquals($settings, $field_settings, "Field {$field_id} has the correct settings.");
  }
}