Skip to content
Snippets Groups Projects
Commit 6751ce84 authored by Aivaras Gotovskis's avatar Aivaras Gotovskis
Browse files

Add FunctionScoreQuery::addFieldValueFactorFunction test.

parent 2b93ee9b
No related branches found
No related tags found
No related merge requests found
<?php
/*
* This file is part of the ONGR package.
*
* (c) NFQ Technologies UAB <info@nfq.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace ONGR\ElasticsearchDSL\Tests\Unit\DSL\Query;
use ONGR\ElasticsearchDSL\BuilderInterface;
use ONGR\ElasticsearchDSL\Query\FunctionScoreQuery;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
* Tests for FunctionScoreQuery.
*/
class FunctionScoreQueryTest extends \PHPUnit_Framework_TestCase
{
/**
* Tests default argument values.
*/
public function testAddFieldValueFactorFunction()
{
/** @var BuilderInterface|MockObject $builderInterface */
$builderInterface = $this->getMockForAbstractClass('ONGR\ElasticsearchDSL\BuilderInterface');
$functionScoreQuery = new FunctionScoreQuery($builderInterface);
$functionScoreQuery->addFieldValueFactorFunction('field1', 2);
$functionScoreQuery->addFieldValueFactorFunction('field2', 1.5, 'ln');
$this->assertSame(
[
'query' => [null => null],
'functions' => [
[
'field_value_factor' => [
'field' => 'field1',
'factor' => 2,
'modifier' => 'none',
],
],
[
'field_value_factor' => [
'field' => 'field2',
'factor' => 1.5,
'modifier' => 'ln',
],
],
],
],
$functionScoreQuery->toArray()
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment