You are here

public function ServerImportTest::setUp in Search API 8

Overrides KernelTestBase::setUp

File

tests/src/Kernel/Server/ServerImportTest.php, line 36

Class

ServerImportTest
Tests that importing a server works correctly.

Namespace

Drupal\Tests\search_api\Kernel\Server

Code

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

  // Create a test server.
  $this->server = Server::create([
    'name' => 'Test Server',
    'id' => 'test_server',
    'status' => 1,
    'backend' => 'search_api_test',
    'backend_config' => [
      'test' => 'foo',
    ],
  ]);
  $this->server
    ->save();
  $config_storage = $this->container
    ->get('config.storage');
  $config_sync = $this->container
    ->get('config.storage.sync');

  // Ensure the "system.site" config exists.
  $config_storage
    ->write('system.site', [
    'uuid' => (new Php())
      ->generate(),
  ]);
  $this
    ->copyConfig($config_storage, $config_sync);
}