public function QueryTest::testQuerySerialization in Search API 8
Tests that serialization of queries works correctly.
File
- tests/
src/ Kernel/ System/ QueryTest.php, line 165
Class
- QueryTest
- Tests query functionality.
Namespace
Drupal\Tests\search_api\Kernel\SystemCode
public function testQuerySerialization() {
$query = Query::create($this->index);
$tags = [
'tag1',
'tag2',
];
$query
->keys('foo bar')
->addCondition('field1', 'value', '<')
->addCondition('field2', [
15,
25,
], 'BETWEEN')
->addConditionGroup($query
->createConditionGroup('OR', $tags)
->addCondition('field2', 'foo')
->addCondition('field3', 1, '<>'))
->sort('field1', Query::SORT_DESC)
->sort('field2');
$query
->setOption('option1', [
'foo' => 'bar',
]);
$translation = $this->container
->get('string_translation');
$query
->setStringTranslation($translation);
$cloned_query = clone $query;
$unserialized_query = unserialize(serialize($query));
$this
->assertEquals($cloned_query, $unserialized_query);
}