public function SerializationTest::testQuerySerialization in Search API 8
Tests that serialization of search queries works correctly.
File
- tests/
src/ Kernel/ System/ SerializationTest.php, line 136
Class
- SerializationTest
- Tests that various classes can be properly serialized and/or cloned.
Namespace
Drupal\Tests\search_api\Kernel\SystemCode
public function testQuerySerialization() {
$query = $this
->createTestQuery();
$serialized = unserialize(serialize($query));
$this
->assertNotEmpty($serialized);
$this
->assertEquals((string) $query, (string) $serialized);
// Call serialize() on the restored query to make "equals" work correctly.
// (__sleep() sets some properties as a by-product which the serialized
// version doesn't have – namely, $indexId and $_serviceIds.)
serialize($serialized);
$this
->assertEquals($query, $serialized);
}