public function SerializationTest::testFieldSerialization in Search API 8
Tests that serialization of fields works correctly.
File
- tests/
src/ Kernel/ System/ SerializationTest.php, line 249
Class
- SerializationTest
- Tests that various classes can be properly serialized and/or cloned.
Namespace
Drupal\Tests\search_api\Kernel\SystemCode
public function testFieldSerialization() {
$field = $this
->createTestField('test', 'entity:entity:entity_test_mulrev_changed');
$serialized = unserialize(serialize($field));
// Call getIndex() and serialize() on the restored field to make "equals"
// work correctly. (__sleep() sets some properties as a by-product which the
// serialized version doesn't have – $indexId, in this case.)
$serialized
->getIndex();
serialize($serialized);
$this
->assertEquals($field, $serialized);
}