equal
deleted
inserted
replaced
4 |
4 |
5 use EasyRdf\Literal; |
5 use EasyRdf\Literal; |
6 |
6 |
7 class DateStatsControllerTest extends TestCase |
7 class DateStatsControllerTest extends TestCase |
8 { |
8 { |
9 const ES_QUERY = [ |
9 private $ES_QUERY; |
10 'index' => 'corpus', |
10 |
11 'body' => [ |
11 public function setUp() { |
12 "size" => 0, |
12 parent::setup(); |
13 "query" => [ "match_all" => [] ], |
13 $this->ES_QUERY = [ |
14 "aggs" => [ |
14 'index' => 'corpus', |
15 "datestats" => [ |
15 'body' => [ |
16 "nested"=> [ |
16 "size" => 0, |
17 "path" => "creation_years" |
17 "query" => [ "match_all" => (object) null ], |
18 ], |
18 "aggs" => [ |
19 "aggs" => [ |
19 "datestats" => [ |
20 "years" => [ |
20 "nested"=> [ |
21 "terms"=> [ |
21 "path" => "creation_years" |
22 "field" => "creation_years.year", |
22 ], |
23 "size" => 0, |
23 "aggs" => [ |
24 "order" => [ |
24 "years" => [ |
25 "_term" => "asc" |
25 "terms"=> [ |
26 ] |
26 "field" => "creation_years.year", |
27 ], |
27 "size" => 2147483647, |
28 "aggs" => [ |
28 "order" => [ |
29 "year_count" => [ |
29 "_term" => "asc" |
30 "sum" => [ |
30 ] |
31 "field" => "creation_years.weight" |
31 ], |
|
32 "aggs" => [ |
|
33 "year_count" => [ |
|
34 "sum" => [ |
|
35 "field" => "creation_years.weight" |
|
36 ] |
32 ] |
37 ] |
33 ] |
38 ] |
34 ] |
39 ] |
35 ] |
40 ] |
36 ] |
41 ] |
37 ] |
42 ] |
38 ] |
43 ] |
39 ] |
44 ]; |
40 ]; |
|
41 |
|
42 public function setUp() { |
|
43 |
|
44 parent::setup(); |
|
45 } |
45 } |
46 |
46 |
47 public function tearDown() { |
47 public function tearDown() { |
48 m::close(); |
48 m::close(); |
49 parent::tearDown(); |
49 parent::tearDown(); |
52 |
52 |
53 public function testIndexQuery() { |
53 public function testIndexQuery() { |
54 |
54 |
55 Es::shouldReceive('search') |
55 Es::shouldReceive('search') |
56 ->once() |
56 ->once() |
57 ->with(self::ES_QUERY) |
57 ->with($this->ES_QUERY) |
58 ->andReturn(json_decode('{ |
58 ->andReturn(json_decode('{ |
59 "took" : 132, |
59 "took" : 132, |
60 "timed_out" : false, |
60 "timed_out" : false, |
61 "_shards" : { |
61 "_shards" : { |
62 "total" : 1, |
62 "total" : 1, |
85 |
85 |
86 public function testIndexResult() { |
86 public function testIndexResult() { |
87 |
87 |
88 Es::shouldReceive('search') |
88 Es::shouldReceive('search') |
89 ->once() |
89 ->once() |
90 ->with(self::ES_QUERY) |
90 ->with($this->ES_QUERY) |
91 ->andReturn(json_decode('{ |
91 ->andReturn(json_decode('{ |
92 "took" : 132, |
92 "took" : 132, |
93 "timed_out" : false, |
93 "timed_out" : false, |
94 "_shards" : { |
94 "_shards" : { |
95 "total" : 1, |
95 "total" : 1, |