TASK: Add new test covering new feature

This commit is contained in:
Daniel Siepmann 2017-11-29 20:00:10 +01:00
parent e3151e802c
commit 5ba860b8de
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4

View file

@ -359,6 +359,54 @@ class QueryFactoryTest extends AbstractUnitTestCase
); );
} }
/**
* @test
*/
public function configuredQueryFieldsAreAddedToQuery()
{
$searchRequest = new SearchRequest('SearchWord');
$this->configuration->expects($this->any())
->method('get')
->withConsecutive(
['searching.fields.query'],
['searching.boost'],
['searching.fields.stored_fields'],
['searching.fields.script_fields'],
['searching.fieldValueFactor']
)
->will($this->onConsecutiveCalls(
'_all, field1, field2',
$this->throwException(new InvalidArgumentException),
$this->throwException(new InvalidArgumentException),
$this->throwException(new InvalidArgumentException),
$this->throwException(new InvalidArgumentException)
));
$query = $this->subject->create($searchRequest);
$this->assertArraySubset(
[
'bool' => [
'must' => [
[
'multi_match' => [
'type' => 'most_fields',
'query' => 'SearchWord',
'fields' => [
'_all',
'field1',
'field2',
],
],
],
],
],
],
$query->toArray()['query'],
'Configured fields were not added to query as configured.'
);
}
/** /**
* @test * @test
*/ */
@ -462,7 +510,6 @@ class QueryFactoryTest extends AbstractUnitTestCase
$query->toArray()['script_fields'], $query->toArray()['script_fields'],
'Script fields were not added to query as expected.' 'Script fields were not added to query as expected.'
); );
} }
/** /**