From 6751ce8428ee61fde8f10263839dc9bc780c119e Mon Sep 17 00:00:00 2001
From: Aivaras Gotovskis <aivaras.gotovskis@ongr.io>
Date: Wed, 8 Jul 2015 10:57:45 +0300
Subject: [PATCH] Add FunctionScoreQuery::addFieldValueFactorFunction test.

---
 tests/Query/FunctionScoreQueryTest.php | 57 ++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)
 create mode 100644 tests/Query/FunctionScoreQueryTest.php

diff --git a/tests/Query/FunctionScoreQueryTest.php b/tests/Query/FunctionScoreQueryTest.php
new file mode 100644
index 0000000..fb83cf0
--- /dev/null
+++ b/tests/Query/FunctionScoreQueryTest.php
@@ -0,0 +1,57 @@
+<?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()
+        );
+    }
+}
-- 
GitLab