You are here

public function ServerTaskTest::setUp in Search API 8

Overrides KernelTestBase::setUp

File

tests/src/Kernel/Server/ServerTaskTest.php, line 70

Class

ServerTaskTest
Tests whether the server task system works correctly.

Namespace

Drupal\Tests\search_api\Kernel\Server

Code

public function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema('user');
  $this
    ->installEntitySchema('search_api_task');
  $this
    ->installSchema('search_api', [
    'search_api_item',
  ]);
  $this
    ->installConfig('search_api');

  // Create a test server.
  $this->server = Server::create([
    'name' => 'Test Server',
    'id' => 'test_server',
    'status' => 1,
    'backend' => 'search_api_test',
  ]);
  $this->server
    ->save();

  // Create a test index.
  $this->index = Index::create([
    'name' => 'Test index',
    'id' => 'test_index',
    'status' => 1,
    'datasource_settings' => [
      'entity:user' => [],
    ],
    'tracker_settings' => [
      'default' => [],
    ],
    'server' => $this->server
      ->id(),
    'options' => [
      'index_directly' => FALSE,
    ],
  ]);
  $this->index
    ->save();
  $this->taskManager = $this->container
    ->get('search_api.task_manager');
  $this->serverTaskManager = $this->container
    ->get('search_api.server_task_manager');

  // Reset the list of called backend methods.
  $this
    ->getCalledMethods('backend');
}