You are here

public function IndexChangesTest::setUp in Search API 8

Overrides KernelTestBase::setUp

File

tests/src/Kernel/Index/IndexChangesTest.php, line 68

Class

IndexChangesTest
Tests correct reactions to changes for the index.

Namespace

Drupal\Tests\search_api\Kernel\Index

Code

public function setUp() {
  parent::setUp();
  $this
    ->installSchema('search_api', [
    'search_api_item',
  ]);
  $this
    ->installEntitySchema('entity_test_mulrev_changed');
  $this
    ->installEntitySchema('search_api_task');
  $this
    ->installEntitySchema('user');
  $this
    ->installConfig('search_api');
  $this->taskManager = $this->container
    ->get('search_api.task_manager');
  User::create([
    'uid' => 1,
    'name' => 'root',
    'langcode' => 'en',
  ])
    ->save();
  EntityTestMulRevChanged::create([
    'id' => 1,
    'name' => 'test 1',
  ])
    ->save();

  // 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 (but don't save it yet).
  $this->index = Index::create([
    'name' => 'Test Index',
    'id' => 'test_index',
    'status' => 1,
    'tracker_settings' => [
      'default' => [],
    ],
    'datasource_settings' => [
      'entity:user' => [],
      'entity:entity_test_mulrev_changed' => [],
    ],
    'server' => $this->server
      ->id(),
    'options' => [
      'index_directly' => FALSE,
    ],
  ]);
  $this->taskManager
    ->deleteTasks();
}