You are here

public function SerializationTest::testServerSerialization in Search API 8

Tests that serialization of server entities doesn't lead to data loss.

File

tests/src/Kernel/System/SerializationTest.php, line 121

Class

SerializationTest
Tests that various classes can be properly serialized and/or cloned.

Namespace

Drupal\Tests\search_api\Kernel\System

Code

public function testServerSerialization() {

  // As our test server, just use the one from the DB Defaults module.
  $path = __DIR__ . '/../../../../modules/search_api_db/search_api_db_defaults/config/optional/search_api.server.default_server.yml';
  $values = Yaml::decode(file_get_contents($path));
  $server = new Server($values, 'search_api_server');
  $serialized = unserialize(serialize($server));
  $this
    ->assertNotEmpty($serialized);
  $this
    ->assertEquals($server, $serialized);
}