File tree Expand file tree Collapse file tree 3 files changed +108
-1
lines changed Expand file tree Collapse file tree 3 files changed +108
-1
lines changed Original file line number Diff line number Diff line change 45
45
"symfony/var-dumper" : " *"
46
46
},
47
47
"require-dev" : {
48
- "phpunit/phpunit" : " 3 .*"
48
+ "phpunit/phpunit" : " 5 .*"
49
49
}
50
50
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Basemkhirat \Elasticsearch \Tests ;
4
+
5
+ use Basemkhirat \Elasticsearch \Tests \Traits \ESQueryTrait ;
6
+
7
+ class BodyTest extends \PHPUnit_Framework_TestCase
8
+ {
9
+
10
+ use ESQueryTrait;
11
+
12
+
13
+ /**
14
+ * Test the body() method.
15
+ * @return void
16
+ */
17
+ public function testBodyMethod ()
18
+ {
19
+
20
+ $ body = [
21
+ "query " => [
22
+ "bool " => [
23
+ "must " => [
24
+ ["match " => ["address " => "mill " ]],
25
+ ]
26
+ ]
27
+ ]
28
+ ];
29
+
30
+ $ this ->assertEquals (
31
+ $ this ->getExpected ($ body ),
32
+ $ this ->getActual ($ body )
33
+ );
34
+
35
+
36
+ }
37
+
38
+ /**
39
+ * Get The expected results.
40
+ * @param $body array
41
+ * @return array
42
+ */
43
+ protected function getExpected ($ body = [])
44
+ {
45
+ $ query = $ this ->getQueryArray ();
46
+
47
+ $ query ["body " ] = $ body ;
48
+
49
+ return $ query ;
50
+ }
51
+
52
+
53
+ /**
54
+ * Get The actual results.
55
+ * @param $body array
56
+ * @return mixed
57
+ */
58
+ protected function getActual ($ body = [])
59
+ {
60
+ return $ this ->getQueryObject ()->body ($ body )->query ();
61
+ }
62
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Basemkhirat \Elasticsearch \Tests ;
4
+
5
+ use Basemkhirat \Elasticsearch \Tests \Traits \ESQueryTrait ;
6
+
7
+ class SelectTest extends \PHPUnit_Framework_TestCase
8
+ {
9
+
10
+ use ESQueryTrait;
11
+
12
+ /**
13
+ * Test the select() method.
14
+ * @return void
15
+ */
16
+ public function testIgnoreMethod ()
17
+ {
18
+ $ this ->assertEquals (
19
+ $ this ->getExpected ("title " , "content " ),
20
+ $ this ->getActual ("title " , "content " )
21
+ );
22
+ }
23
+
24
+ /**
25
+ * Get The expected results.
26
+ * @return array
27
+ */
28
+ protected function getExpected ()
29
+ {
30
+ $ query = $ this ->getQueryArray ();
31
+
32
+ $ query ["body " ]["_source " ] = func_get_args ();
33
+
34
+ return $ query ;
35
+ }
36
+
37
+ /**
38
+ * Get The actual results.
39
+ * @return mixed
40
+ */
41
+ protected function getActual ()
42
+ {
43
+ return $ this ->getQueryObject ()->select (func_get_args ())->query ();
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments