public function ProcessorTestBase::setUp in Search API 8
Performs setup tasks before each individual test method is run.
Installs commonly used schemas and sets up a search server and an index, with the specified processor enabled.
Parameters
string|null $processor: (optional) The plugin ID of the processor that should be set up for testing.
Overrides KernelTestBase::setUp
9 calls to ProcessorTestBase::setUp()
- AddHierarchyTest::setUp in tests/
src/ Kernel/ Processor/ AddHierarchyTest.php  - Performs setup tasks before each individual test method is run.
 - AddURLKernelTest::setUp in tests/
src/ Kernel/ Processor/ AddURLKernelTest.php  - Performs setup tasks before each individual test method is run.
 - ContentAccessTest::setUp in tests/
src/ Kernel/ Processor/ ContentAccessTest.php  - Performs setup tasks before each individual test method is run.
 - LanguageWithFallbackTest::setUp in tests/
src/ Kernel/ Processor/ LanguageWithFallbackTest.php  - Performs setup tasks before each individual test method is run.
 - NumberFieldBoostTest::setUp in tests/
src/ Kernel/ Processor/ NumberFieldBoostTest.php  - Performs setup tasks before each individual test method is run.
 
9 methods override ProcessorTestBase::setUp()
- AddHierarchyTest::setUp in tests/
src/ Kernel/ Processor/ AddHierarchyTest.php  - Performs setup tasks before each individual test method is run.
 - AddURLKernelTest::setUp in tests/
src/ Kernel/ Processor/ AddURLKernelTest.php  - Performs setup tasks before each individual test method is run.
 - ContentAccessTest::setUp in tests/
src/ Kernel/ Processor/ ContentAccessTest.php  - Performs setup tasks before each individual test method is run.
 - LanguageWithFallbackTest::setUp in tests/
src/ Kernel/ Processor/ LanguageWithFallbackTest.php  - Performs setup tasks before each individual test method is run.
 - NumberFieldBoostTest::setUp in tests/
src/ Kernel/ Processor/ NumberFieldBoostTest.php  - Performs setup tasks before each individual test method is run.
 
File
- tests/
src/ Kernel/ Processor/ ProcessorTestBase.php, line 63  
Class
- ProcessorTestBase
 - Provides a base class for Drupal unit tests for processors.
 
Namespace
Drupal\Tests\search_api\Kernel\ProcessorCode
public function setUp($processor = NULL) {
  parent::setUp();
  $this
    ->installSchema('node', [
    'node_access',
  ]);
  $this
    ->installSchema('search_api', [
    'search_api_item',
  ]);
  $this
    ->installEntitySchema('user');
  $this
    ->installEntitySchema('node');
  $this
    ->installEntitySchema('comment');
  $this
    ->installEntitySchema('search_api_task');
  $this
    ->installSchema('comment', [
    'comment_entity_statistics',
  ]);
  $this
    ->installConfig([
    'field',
  ]);
  $this
    ->installConfig('search_api');
  // Do not use a batch for tracking the initial items after creating an
  // index when running the tests via the GUI. Otherwise, it seems Drupal's
  // Batch API gets confused and the test fails.
  if (!Utility::isRunningInCli()) {
    \Drupal::state()
      ->set('search_api_use_tracking_batch', FALSE);
  }
  $this->server = Server::create([
    'id' => 'server',
    'name' => 'Server & Name',
    'status' => TRUE,
    'backend' => 'search_api_db',
    'backend_config' => [
      'min_chars' => 3,
      'database' => 'default:default',
    ],
  ]);
  $this->server
    ->save();
  $this->index = Index::create([
    'id' => 'index',
    'name' => 'Index name',
    'status' => TRUE,
    'datasource_settings' => [
      'entity:comment' => [],
      'entity:node' => [],
    ],
    'server' => 'server',
    'tracker_settings' => [
      'default' => [],
    ],
  ]);
  $this->index
    ->setServer($this->server);
  $field_subject = new Field($this->index, 'subject');
  $field_subject
    ->setType('text');
  $field_subject
    ->setPropertyPath('subject');
  $field_subject
    ->setDatasourceId('entity:comment');
  $field_subject
    ->setLabel('Subject');
  $field_title = new Field($this->index, 'title');
  $field_title
    ->setType('text');
  $field_title
    ->setPropertyPath('title');
  $field_title
    ->setDatasourceId('entity:node');
  $field_title
    ->setLabel('Title');
  $this->index
    ->addField($field_subject);
  $this->index
    ->addField($field_title);
  if ($processor) {
    $this->processor = \Drupal::getContainer()
      ->get('search_api.plugin_helper')
      ->createProcessorPlugin($this->index, $processor);
    $this->index
      ->addProcessor($this->processor);
  }
  $this->index
    ->save();
}