You are here

public function ServerImportTest::testServerImport in Search API 8

Tests that importing new server config works correctly.

File

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

Class

ServerImportTest
Tests that importing a server works correctly.

Namespace

Drupal\Tests\search_api\Kernel\Server

Code

public function testServerImport() {

  // Stolen from
  // \Drupal\Tests\system\Kernel\Entity\ConfigEntityImportTest::assertConfigUpdateImport().
  $name = $this->server
    ->getConfigDependencyName();
  $original_data = $this->server
    ->toArray();
  $custom_data = $original_data;
  $custom_data['name'] = 'Old test server';
  $custom_data['backend_config']['test'] = 'bar';
  $this->container
    ->get('config.storage.sync')
    ->write($name, $custom_data);

  // Verify the active configuration still returns the default values.
  $config = $this
    ->config($name);
  $this
    ->assertSame($config
    ->get(), $original_data);

  // Import.
  $this
    ->configImporter()
    ->import();

  // Verify the values were updated.
  $this->container
    ->get('config.factory')
    ->reset($name);
  $config = $this
    ->config($name);
  $this
    ->assertSame($config
    ->get(), $custom_data);
}