Skip to content

Commit d35c098

Browse files
committed
fix test
1 parent e081e5d commit d35c098

File tree

3 files changed

+108
-1
lines changed

3 files changed

+108
-1
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@
4545
"symfony/var-dumper": "*"
4646
},
4747
"require-dev": {
48-
"phpunit/phpunit": "3.*"
48+
"phpunit/phpunit": "5.*"
4949
}
5050
}

tests/BodyTest.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
}

tests/SelectTest.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
}

0 commit comments

Comments
 (0)