You are here

public function ConfigOverrideKernelTest::setUp in Search API 8

Overrides KernelTestBase::setUp

File

tests/src/Kernel/ConfigEntity/ConfigOverrideKernelTest.php, line 49

Class

ConfigOverrideKernelTest
Contains tests for config entities with overrides.

Namespace

Drupal\Tests\search_api\Kernel\ConfigEntity

Code

public function setUp() {
  parent::setUp();

  // Set up necessary schemas.
  $this
    ->installSchema('search_api', [
    'search_api_item',
  ]);
  $this
    ->installSchema('user', [
    'users_data',
  ]);
  $this
    ->installEntitySchema('user');
  $this
    ->installEntitySchema('search_api_task');
  $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);
  }

  // Set up overrides.
  $GLOBALS['config']['search_api.server.test_server'] = [
    'name' => 'Overridden server',
    'backend' => 'search_api_test',
    'backend_config' => [
      'test' => 'foobar',
    ],
  ];
  $GLOBALS['config']['search_api.index.test_index'] = [
    'name' => 'Overridden index',
    'server' => 'test_server',
    'processor_settings' => [
      'search_api_test' => [],
    ],
  ];

  // Create a test server and index.
  $this->server = Server::create([
    'id' => 'test_server',
    'name' => 'Test server',
    'backend' => 'does not exist',
  ]);
  $this->index = Index::create([
    'id' => 'test_index',
    'name' => 'Test index',
    'server' => 'unknown_server',
    'datasource_settings' => [
      'entity:user' => [],
    ],
    'tracker_settings' => [
      'default' => [],
    ],
  ]);
}