public function BackendPluginBaseTest::testGetQueryFulltextFields in Search API 8
Tests whether fulltext fields are correctly extracted from queries.
@covers ::getQueryFulltextFields
@dataProvider getQueryFulltextFieldsDataProvider
Parameters
string[]|null $query_fields: The fulltext fields set explicitly on the query, if any.
string[] $expected: The field IDs that are expected to be returned.
File
- tests/
src/ Unit/ BackendPluginBaseTest.php, line 31
Class
- BackendPluginBaseTest
- Tests methods provided by the backend plugin base class.
Namespace
Drupal\Tests\search_api\UnitCode
public function testGetQueryFulltextFields($query_fields, array $expected) {
$index = $this
->createMock(IndexInterface::class);
$index
->method('getFulltextFields')
->willReturn([
'field1',
'field2',
]);
$query = $this
->createMock(QueryInterface::class);
$query
->method('getFulltextFields')
->willReturn($query_fields);
$query
->method('getIndex')
->willReturn($index);
$backend = new TestBackend([], '', []);
$class = new \ReflectionClass(TestBackend::class);
$method = $class
->getMethod('getQueryFulltextFields');
$method
->setAccessible(TRUE);
$this
->assertEquals($expected, $method
->invokeArgs($backend, [
$query,
]));
}